|
@@ -1,5 +1,5 @@
|
|
|
const { getShopDetail } = require('../../api/common')
|
|
|
-const { getProductDetail } = require('./api/index')
|
|
|
+const { getProductDetail, postProductCollect } = require('./api/index')
|
|
|
|
|
|
Page({
|
|
|
|
|
@@ -8,7 +8,8 @@ Page({
|
|
|
*/
|
|
|
data: {
|
|
|
searchForm: {
|
|
|
- product_id: ''
|
|
|
+ product_id: '',
|
|
|
+ type: -1
|
|
|
},
|
|
|
nav: [
|
|
|
{
|
|
@@ -25,7 +26,8 @@ Page({
|
|
|
product_rotation_img_list: [],
|
|
|
product_detail_img_list: []
|
|
|
},
|
|
|
- objShopDetail: { shop_address: {} }
|
|
|
+ objShopDetail: { shop_address: {} },
|
|
|
+ booLock: false
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -100,7 +102,8 @@ Page({
|
|
|
product_rotation_img_list: JSON.parse(product_rotation_img_list),
|
|
|
product_detail_img_list: JSON.parse(product_detail_img_list)
|
|
|
},
|
|
|
- 'searchForm.shop_id': shop_id
|
|
|
+ 'searchForm.shop_id': shop_id,
|
|
|
+ 'searchForm.type': 1 // todo
|
|
|
}, () => {
|
|
|
this.fetchShopDetail()
|
|
|
})
|
|
@@ -130,6 +133,34 @@ Page({
|
|
|
}
|
|
|
} catch (err) {}
|
|
|
},
|
|
|
+ async productCollect() {
|
|
|
+ const { type, product_id } = this.data.searchForm
|
|
|
+ const _type = type === 1 ? 2 : 1
|
|
|
+
|
|
|
+ this.setData({
|
|
|
+ booLock: true
|
|
|
+ })
|
|
|
+ try {
|
|
|
+ const {
|
|
|
+ status,
|
|
|
+ msg
|
|
|
+ } = await postProductCollect(product_id, _type)
|
|
|
+ if (status) {
|
|
|
+ this.setData({
|
|
|
+ 'searchForm.type': _type
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ wx.showToast({
|
|
|
+ title: msg,
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } catch (err) {}
|
|
|
+
|
|
|
+ this.setData({
|
|
|
+ booLock: false
|
|
|
+ })
|
|
|
+ },
|
|
|
handleNav(e) {
|
|
|
const { value } = e.detail
|
|
|
|