Authored by baoss

替换模板消息 review by bevishuang

import api from '../common/api';
import config from '../common/config.js'
import config from '../common/config.js';
export default {
getUnionTypeWithUid(uid) {
let param = {
... ... @@ -13,46 +13,53 @@ export default {
});
},
postTmplId(params) {
let app = getApp();
let that = this;
//如果没有uid,不上报,否则接口报500
if (!app.getUid() || params.tmplIds.length === 0) return
return new Promise(resolve => {
wx.requestSubscribeMessage({
tmplIds: params.tmplIds,
success(res) {
console.log(res)
let tmplIds = res
delete tmplIds.errMsg
tmplIds = JSON.stringify(tmplIds)
//上报tmplIds
let tmplIdParams = {
uid: app.getUid(),
openId: app.getOpenID(),
miniAppType: config.mini_app_type,
templateIds: tmplIds,
method: 'mini.subscribe.add',
let app = getApp();
let that = this;
// 如果没有uid,不上报,否则接口报500
if (!app.getUid() || params.tmplIds.length === 0) {
return;
}
return new Promise(resolve => {
wx.requestSubscribeMessage({
tmplIds: params.tmplIds,
success(res) {
console.log(res);
let tmplIds = res;
delete tmplIds.errMsg;
tmplIds = JSON.stringify(tmplIds);
// 上报tmplIds
let tmplIdParams = {
uid: app.getUid(),
openId: app.getOpenID(),
miniAppType: config.mini_app_type,
templateIds: tmplIds,
method: 'mini.subscribe.add',
};
console.log('params', tmplIdParams);
api.get({
data: tmplIdParams
}).then(res => {
resolve(res);
});
},
fail(res) {
console.log(res);
wx.showToast({
title: res.errCode === 20004 ? '消息未开启 请点击右上角,打开设置,开启消息' : res.errMsg,
icon: 'none',
duration: 3000,
});
setTimeout(function() {
resolve();
}, 3000);
}
console.log('params', tmplIdParams)
api.get({
data: tmplIdParams
}).then(res => {
resolve(res)
})
},
fail(res) {
console.log(res)
wx.showToast({
title: res.errCode === 20004 ? '消息未开启 请点击右上角,打开设置,开启消息' : res.errMsg,
icon: 'none',
duration: 3000,
})
setTimeout(function () {
resolve()
}, 3000)
}
})
})
});
});
}
}
};
... ...
... ... @@ -134,7 +134,7 @@ Page({
}
that.setData({
listData: list,
footText: list.length > 0 ? '':'暂无更多内容'
footText: list.length > 0 ? '' : '暂无更多内容'
});
}
});
... ...
... ... @@ -11,7 +11,7 @@ import {
stringify
} from '../../../vendors/query-stringify';
import wx from '../../../utils/wx';
import commonService from '../../../models/common.js'
import commonService from '../../../models/common.js';
let app = getApp();
let router = global.router;
let yas;
... ... @@ -80,7 +80,7 @@ const QUEUE_SUCCESS = {
const OFFLINE_STATUS = {
OFFLINE: 1,
OFFLINE_OVER: 0
}
};
const YB_TO_ASSIST_C = 'YB_TO_ASSIST_C';
const YB_ASSIST_SUCCESS_L = 'YB_ASSIST_SUCCESS_L';
const YB_INVITE_ASSIST_C = 'YB_INVITE_ASSIST_C';
... ... @@ -168,8 +168,9 @@ Page(Object.assign({
});
let userInfo = app.getUserInfo();
if (!userInfo.wechat || !this.getUserWechatId()) {
this.goLogin({'login': '0', 'type': 'redirectTo'});
this.goLogin({login: '0', type: 'redirectTo'});
return;
}
... ... @@ -551,7 +552,7 @@ Page(Object.assign({
let userInfo = app.getUserInfo();
if (!userInfo.wechat || !this.getUserWechatId()) {
this.goLogin({'login': '0'});
this.goLogin({login: '0'});
return;
}
... ... @@ -615,7 +616,7 @@ Page(Object.assign({
let userInfo = app.getUserInfo();
if (!userInfo.wechat || !this.getUserWechatId()) {
this.goLogin({'login': '0'});
this.goLogin({login: '0'});
return;
}
... ... @@ -704,19 +705,21 @@ Page(Object.assign({
});
},
toFollow() {
let that = this
if(this.data.isFollow) {
return
let that = this;
if (this.data.isFollow) {
return;
}
let tmplIds = ['WhCBCAO2ci_gSrDSzpMExhYAdnhlF0aqgr2YWzJG4EM','3KKWG1j-1ui2wE19aLcpCVSoKTsbWpnlmPIBLesHJqs'];
let tmplIds = ['WhCBCAO2ci_gSrDSzpMExhYAdnhlF0aqgr2YWzJG4EM', '3KKWG1j-1ui2wE19aLcpCVSoKTsbWpnlmPIBLesHJqs'];
commonService.postTmplId({
tmplIds
}).then(res => {
that.setData({
isFollow: true
})
})
});
});
},
assistCancel() {
this.reload();
... ... @@ -793,8 +796,8 @@ Page(Object.assign({
},
goLogin(params) {
let login = parseInt(params['login']) || 1;
let type = params['type'] || 'navigateTo';
let login = parseInt(params.login) || 1;
let type = params.type || 'navigateTo';
let data = {};
if (this.data.originUid) {
... ...
... ... @@ -97,7 +97,7 @@ function wechatPay(order) {
signType: data.signType,
paySign: data.paySign,
success: function() {
reportPayStatus(orderCode, orderAmount, true);
... ...