|
@@ -4,7 +4,8 @@ import {
|
|
|
getResourceList
|
|
|
} from "~/api/works"
|
|
|
import {
|
|
|
- getBannerList
|
|
|
+ getBannerList,
|
|
|
+ setSubscribe
|
|
|
} from '~/api/global'
|
|
|
import event from '~/mixins/event'
|
|
|
import share from '~/mixins/share'
|
|
@@ -22,6 +23,8 @@ Page({
|
|
|
bannerList: [],
|
|
|
categoryList: [],
|
|
|
listOptions: {},
|
|
|
+ subscribeShow: false,
|
|
|
+ tmplIds: []
|
|
|
},
|
|
|
onLoad(options) {
|
|
|
this.getLocUserInfo()
|
|
@@ -47,7 +50,6 @@ Page({
|
|
|
})
|
|
|
}, 6000)
|
|
|
}
|
|
|
- this.requestMessage()
|
|
|
},
|
|
|
onShow() {
|
|
|
if (typeof this.getTabBar === 'function') {
|
|
@@ -60,6 +62,7 @@ Page({
|
|
|
this.getBannerList()
|
|
|
this.getResource()
|
|
|
this.getCategoryList()
|
|
|
+ this.getSubscribe()
|
|
|
},
|
|
|
async getLocUserInfo() {
|
|
|
this.storeBindings = createStoreBindings(this, {
|
|
@@ -126,11 +129,33 @@ Page({
|
|
|
url: '/pages/childClassify/index?type=search',
|
|
|
})
|
|
|
},
|
|
|
+ async getSubscribe() {
|
|
|
+ let tmplIds = await setSubscribe()
|
|
|
+ console.log(tmplIds);
|
|
|
+ this.setData({
|
|
|
+ tmplIds: tmplIds ? tmplIds : [],
|
|
|
+ subscribeShow: tmplIds ? true : false,
|
|
|
+ })
|
|
|
+ },
|
|
|
requestMessage() {
|
|
|
- /* wx.requestSubscribeMessage({
|
|
|
- tmplIds: [''],
|
|
|
- success(res) {}
|
|
|
- }) */
|
|
|
+ wx.requestSubscribeMessage({
|
|
|
+ tmplIds: this.data.tmplIds,
|
|
|
+ success: async (res) => {
|
|
|
+ console.log(res);
|
|
|
+ let accept = []
|
|
|
+ this.data.tmplIds.forEach(item => {
|
|
|
+ console.log(res[item]);
|
|
|
+ if (res[item] == 'accept') {
|
|
|
+ accept.push(item)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ let subscribeRes = await setSubscribe({
|
|
|
+ ids: accept
|
|
|
+ }, 'post')
|
|
|
+ console.log(subscribeRes);
|
|
|
+ this.getSubscribe()
|
|
|
+ }
|
|
|
+ })
|
|
|
},
|
|
|
onUnload() {
|
|
|
this.storeBindings.destroyStoreBindings()
|