|
170 | 170 | this.$u.vuex('referrer', scene.split(',')[1]) |
171 | 171 | } |
172 | 172 | } |
173 | | - this._goodsDetail(e.id) |
| 173 | + this._goodsDetail(e.id, e.supplyType, e.yyId) |
174 | 174 | }, |
175 | 175 | onShow() { |
176 | 176 |
|
|
185 | 185 |
|
186 | 186 | }, |
187 | 187 | methods: { |
188 | | - async _goodsDetail(goodsId) { |
189 | | - // https://www.yuque.com/apifm/nu0f75/vuml8a |
190 | | - const res = await this.$wxapi.goodsDetail(goodsId, this.token) |
191 | | - if (res.code != 0) { |
192 | | - uni.showToast({ |
193 | | - title: res.msg, |
194 | | - icon: 'none' |
195 | | - }) |
196 | | - setTimeout(() => { |
197 | | - uni.navigateBack() |
198 | | - }, 3000) |
199 | | - return |
| 188 | + async _goodsDetail(goodsId, supplyType, yyId) { |
| 189 | + if(goodsId) { |
| 190 | + // https://www.yuque.com/apifm/nu0f75/vuml8a |
| 191 | + const res = await this.$wxapi.goodsDetail(goodsId, this.token) |
| 192 | + if (res.code != 0) { |
| 193 | + uni.showToast({ |
| 194 | + title: res.msg, |
| 195 | + icon: 'none' |
| 196 | + }) |
| 197 | + setTimeout(() => { |
| 198 | + uni.navigateBack() |
| 199 | + }, 3000) |
| 200 | + return |
| 201 | + } |
| 202 | + this.goodsDetail = res.data |
| 203 | + } else { |
| 204 | + // 不是api工厂商品 |
| 205 | + this.goodsDetail = { |
| 206 | + basicInfo: { |
| 207 | + yyId: yyId, |
| 208 | + yyIdStr: yyId, |
| 209 | + supplyType: supplyType, |
| 210 | + pic: '', |
| 211 | + name: '', |
| 212 | + stores: 999999 |
| 213 | + }, |
| 214 | + pics: [] |
| 215 | + } |
200 | 216 | } |
201 | | - this.goodsDetail = res.data |
202 | 217 | // 检测是否收藏 |
203 | 218 | this.goodsFavCheck() |
204 | 219 | this._reputationList() |
|
225 | 240 | this.jdGoodsDetail = res.data |
226 | 241 | this.goodsDetail.basicInfo.minPrice = this.jdGoodsDetail.price.priceSale |
227 | 242 | this.goodsDetail.basicInfo.originalPrice = this.jdGoodsDetail.price.priceJd |
228 | | - this.goodsDetail.basicInfo.name = this.jdGoodsDetail.price.skuName |
| 243 | + this.goodsDetail.basicInfo.name = this.jdGoodsDetail.price.skuName |
| 244 | + this.goodsDetail.basicInfo.pic = this.jdGoodsDetail.imageDomain + this.jdGoodsDetail.price.pic |
229 | 245 | if (this.jdGoodsDetail.info.wxintroduction) { |
230 | 246 | this.wxintroduction = JSON.parse(this.jdGoodsDetail.info.wxintroduction) |
231 | 247 | } |
|
268 | 284 | // this.goodsDetail.content = res.data.usageGuide |
269 | 285 | this.wxintroduction = res.data.pics |
270 | 286 | }, |
271 | | - goCart() { |
| 287 | + goCart() { |
| 288 | + if(this.goodsDetail.basicInfo.supplyType == 'vop_jd') { |
| 289 | + uni.setStorageSync('cart_tabIndex', 1) |
| 290 | + } |
272 | 291 | uni.switchTab({ |
273 | 292 | url: "/pages/cart/index" |
274 | 293 | }) |
275 | 294 | }, |
276 | | - async goodsFavCheck() { |
| 295 | + async goodsFavCheck() { |
| 296 | + const data = { |
| 297 | + token: this.token, |
| 298 | + type: 0, |
| 299 | + goodsId: this.goodsDetail.basicInfo.id |
| 300 | + } |
| 301 | + if(this.goodsDetail.basicInfo.supplyType == 'vop_jd') { |
| 302 | + data.type = 1 |
| 303 | + data.goodsId = this.goodsDetail.basicInfo.yyId |
| 304 | + } |
277 | 305 | // https://www.yuque.com/apifm/nu0f75/ugf7y9 |
278 | | - const res = await this.$wxapi.goodsFavCheckV2({ |
279 | | - token: this.token, |
280 | | - type: 0, |
281 | | - goodsId: this.goodsDetail.basicInfo.id |
282 | | - }) |
| 306 | + const res = await this.$wxapi.goodsFavCheckV2(data) |
283 | 307 | if (res.code == 0) { |
284 | 308 | this.faved = true |
285 | 309 | } else { |
286 | 310 | this.faved = false |
287 | 311 | } |
288 | 312 | }, |
289 | | - async addFav() { |
| 313 | + async addFav() { |
| 314 | + const data = { |
| 315 | + token: this.token, |
| 316 | + type: 0, |
| 317 | + goodsId: this.goodsDetail.basicInfo.id |
| 318 | + } |
| 319 | + if(this.goodsDetail.basicInfo.supplyType == 'vop_jd') { |
| 320 | + data.type = 1 |
| 321 | + data.goodsId = this.goodsDetail.basicInfo.yyId |
| 322 | + } |
290 | 323 | if (this.faved) { |
291 | 324 | // 取消收藏 https://www.yuque.com/apifm/nu0f75/zy4sil |
292 | | - const res = await this.$wxapi.goodsFavDeleteV2({ |
293 | | - token: this.token, |
294 | | - type: 0, |
295 | | - goodsId: this.goodsDetail.basicInfo.id |
296 | | - }) |
| 325 | + const res = await this.$wxapi.goodsFavDeleteV2(data) |
297 | 326 | if (res.code == 0) { |
298 | 327 | this.faved = false |
299 | 328 | } else { |
|
302 | 331 | icon: 'none' |
303 | 332 | }) |
304 | 333 | } |
305 | | - } else { |
| 334 | + } else { |
| 335 | + const extJsonStr = { |
| 336 | + pic: this.goodsDetail.basicInfo.pic, |
| 337 | + goodsName: this.goodsDetail.basicInfo.name, |
| 338 | + supplyType: this.goodsDetail.basicInfo.supplyType |
| 339 | + } |
| 340 | + data.extJsonStr = JSON.stringify(extJsonStr) |
306 | 341 | // 加入收藏 https://www.yuque.com/apifm/nu0f75/mr1471 |
307 | | - const res = await this.$wxapi.goodsFavAdd({ |
308 | | - token: this.token, |
309 | | - type: 0, |
310 | | - goodsId: this.goodsDetail.basicInfo.id |
311 | | - }) |
| 342 | + const res = await this.$wxapi.goodsFavAdd(data) |
312 | 343 | if (res.code == 0) { |
313 | 344 | this.faved = true |
314 | 345 | } else { |
|
0 commit comments