|
@@ -1,5 +1,6 @@
|
|
|
const pages = require('../../mixin/pages')
|
|
|
const { getShopDetail } = require('../../api/common')
|
|
|
+const { postShopCollect } = require('./api/index')
|
|
|
|
|
|
Page({
|
|
|
|
|
@@ -12,7 +13,6 @@ Page({
|
|
|
searchForm: {
|
|
|
shop_id: ''
|
|
|
},
|
|
|
- background: ['demo-text-1', 'demo-text-2', 'demo-text-3'],
|
|
|
nav: [
|
|
|
{
|
|
|
name: '详情',
|
|
@@ -24,7 +24,8 @@ Page({
|
|
|
}
|
|
|
],
|
|
|
active: '1',
|
|
|
- objShopDetail: {shop_address: {}}
|
|
|
+ objShopDetail: { shop_address: {} },
|
|
|
+ booLock: false
|
|
|
},
|
|
|
...pages.methods,
|
|
|
/**
|
|
@@ -97,11 +98,13 @@ Page({
|
|
|
try {
|
|
|
const { status, data, msg } = await getShopDetail(this.data.searchForm.shop_id)
|
|
|
if (status) {
|
|
|
+ const { shop_address, collect_status } = data
|
|
|
this.setData({
|
|
|
objShopDetail: {
|
|
|
...data,
|
|
|
- shop_address: JSON.parse(data.shop_address)
|
|
|
- }
|
|
|
+ shop_address: JSON.parse(shop_address)
|
|
|
+ },
|
|
|
+ 'searchForm.type': collect_status === 0 ? 1 : 2 // 是否收藏(0否1是)
|
|
|
})
|
|
|
} else {
|
|
|
wx.showToast({
|
|
@@ -111,6 +114,33 @@ Page({
|
|
|
}
|
|
|
} catch (err) {}
|
|
|
},
|
|
|
+ async shopCollect() {
|
|
|
+ const { type, shop_id } = this.data.searchForm
|
|
|
+
|
|
|
+ if (this.data.booLock) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.setData({
|
|
|
+ booLock: true
|
|
|
+ })
|
|
|
+ try {
|
|
|
+ const { status, msg } = await postShopCollect(shop_id, type)
|
|
|
+ if (status) {
|
|
|
+ this.setData({
|
|
|
+ 'searchForm.type': type === 1 ? 2 : 1
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ wx.showToast({
|
|
|
+ title: msg,
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } catch (err) {}
|
|
|
+
|
|
|
+ this.setData({
|
|
|
+ booLock: false
|
|
|
+ })
|
|
|
+ },
|
|
|
handleNav(e) {
|
|
|
const { value } = e.detail
|
|
|
|