Commit 966fda91 by 李嘉林

支付成功订阅消息

parent 08e039c9
......@@ -10,6 +10,11 @@ export default {
`${process.env.OLSHOP_URL}/shop/getWxMiniSubscribeMessageConfig`
);
},
addWxMiniSubscribeMessageRecord(data) {
return requestPOST(
`${process.env.OLSHOP_URL}/shop/addWxMiniSubscribeMessageRecord`, data
);
},
// 页面数据
themePagesInfo(params) {
return requestPOST(
......
......@@ -40,6 +40,11 @@
</div>
</template>
</div>
<!-- 订阅消息 -->
<div class="subscribe" v-if="miniIdlist.length>0">
<p class="info">订阅消息及时获得物流信息及状态通知</p>
<van-switch :checked="checkedSubscribe" @change="changeCheckedSubscribe" active-color="var(--minor-color)" size="20" />
</div>
</div>
</div>
<div class="line" v-if="orderDetail.orderType == 5"></div>
......@@ -93,6 +98,7 @@
</template>
<script>
import shop from "@/api/shop";
const app = getApp();
const { log } = app;
export default {
......@@ -128,6 +134,13 @@ export default {
default: 0,
},
},
data() {
return {
checkedSubscribe: false, // 订阅消息开关
miniMsgList: [],
miniIdlist: [],
}
},
computed: {
icon() {
return this.datas.componentData["icon"]||'http://mayi-newshop.oss-cn-shanghai.aliyuncs.com/public/png/83a4a0bc-37fc-411e-bc5c-6dd9c1b4a921.png';
......@@ -170,8 +183,23 @@ export default {
},
onLoad() {
console.log("-----------------------info",this.$store.state.spokemanInfo)
this.checkedSubscribe = false;
this.getWxMiniSubscribeMessageConfig();
},
methods: {
getWxMiniSubscribeMessageConfig() {
shop.getWxMiniSubscribeMessageConfig().then(res => {
if (res.data.code == 200) {
const data = res.data.data;
log.info("wx mini subscribe message data: ", data);
console.log(data.miniMessageConfigResponseDTOList,'-------------data')
if(data.miniMessageConfigResponseDTOList && data.miniMessageConfigResponseDTOList.length>0) {
this.miniMsgList = data.miniMessageConfigResponseDTOList;
this.miniIdlist = this.miniMsgList.map(item=>item.priTmplId);
}
}
});
},
toOrderDetail() {
if (!this.render) return;
console.log("查看详情");
......@@ -180,6 +208,46 @@ export default {
url,
});
},
changeCheckedSubscribe(val) {
console.log(val,'--------------')
this.checkedSubscribe = val.mp.detail;
if(this.checkedSubscribe) {
this.toDingyue();
}
},
toDingyue() {
let _this = this;
if(!(this.miniIdlist && this.miniIdlist.length>0)) {
return;
}
wx.requestSubscribeMessage({
tmplIds: _this.miniIdlist,
success(res) {
log.info("用户点击订阅",res)
let showToast = false;
console.log(res, "-------------res");
_this.miniIdlist.forEach(item=>{
if(res[item] == "accept"){
showToast = true;
}
})
if(showToast) {
wx.showToast({title:"订阅成功",icon:"none"});
}
_this.miniMsgList.forEach(item=>{
let query = {
openId: wx.getStorageSync("openid"),
eventName: item.title,
eventType: item.definitionType,
sendTemplateId: item.priTmplId,
sendTemplateParams: item.content,
extraParams: item.example,
}
shop.addWxMiniSubscribeMessageRecord(query).then()
})
},
});
},
toOrderList() {
let url = `/pages/index/main?from=home&backpath=${encodeURIComponent(`/order/orderList`)}`
wx.redirectTo({
......@@ -272,7 +340,7 @@ export default {
margin-top: 1px;
overflow: hidden;
.paySuccess_detail {
padding: 0 63px;
padding: 0 30px;
.iconPay {
margin: 0 auto;
border-radius: 50%;
......@@ -327,9 +395,9 @@ export default {
}
.bottom {
margin-top: 10px;
justify-content: space-around;
justify-content: space-between;
/deep/.van-button {
width: 118px;
width: 140px;
height: 35px;
color: #929292;
line-height: 35px;
......@@ -342,6 +410,19 @@ export default {
color: #fff;
}
}
.subscribe{
padding: 8px 18px;
display: flex;
justify-content: space-between;
align-items: center;
background: var(--main-color);
margin-top: 20px;
border-radius: 6px;
p.info{
color: #fff;
font-size: 13px;
}
}
}
}
......
......@@ -481,17 +481,6 @@ export default {
return JSON.stringify(pageData);
},
toDingyue() {
wx.requestSubscribeMessage({
tmplIds: [
"cTgB0EMEibieOPU6HWPbmr3YCea7MZYCryxmi2_fS5o",
"pWi2-icKybK1fSSjRf-wrsQE1jmsuEp1QgPTAxn2nB0",
],
success(res) {
console.log(res, "-------------res");
},
});
},
},
};
</script>
......
......@@ -3,6 +3,7 @@
"usingComponents": {
"van-checkbox": "/static/vant/checkbox/index",
"van-popup":"/static/vant/popup/index",
"van-switch":"/static/vant/switch/index",
"van-button":"/static/vant/button/index",
"van-picker": "/static/vant/picker/index",
"van-icon":"/static/vant/icon/index",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment