Commit 966fda91 by 李嘉林

支付成功订阅消息

parent 08e039c9
...@@ -10,6 +10,11 @@ export default { ...@@ -10,6 +10,11 @@ export default {
`${process.env.OLSHOP_URL}/shop/getWxMiniSubscribeMessageConfig` `${process.env.OLSHOP_URL}/shop/getWxMiniSubscribeMessageConfig`
); );
}, },
addWxMiniSubscribeMessageRecord(data) {
return requestPOST(
`${process.env.OLSHOP_URL}/shop/addWxMiniSubscribeMessageRecord`, data
);
},
// 页面数据 // 页面数据
themePagesInfo(params) { themePagesInfo(params) {
return requestPOST( return requestPOST(
......
...@@ -40,6 +40,11 @@ ...@@ -40,6 +40,11 @@
</div> </div>
</template> </template>
</div> </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> </div>
<div class="line" v-if="orderDetail.orderType == 5"></div> <div class="line" v-if="orderDetail.orderType == 5"></div>
...@@ -93,6 +98,7 @@ ...@@ -93,6 +98,7 @@
</template> </template>
<script> <script>
import shop from "@/api/shop";
const app = getApp(); const app = getApp();
const { log } = app; const { log } = app;
export default { export default {
...@@ -128,6 +134,13 @@ export default { ...@@ -128,6 +134,13 @@ export default {
default: 0, default: 0,
}, },
}, },
data() {
return {
checkedSubscribe: false, // 订阅消息开关
miniMsgList: [],
miniIdlist: [],
}
},
computed: { computed: {
icon() { icon() {
return this.datas.componentData["icon"]||'http://mayi-newshop.oss-cn-shanghai.aliyuncs.com/public/png/83a4a0bc-37fc-411e-bc5c-6dd9c1b4a921.png'; 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 { ...@@ -170,8 +183,23 @@ export default {
}, },
onLoad() { onLoad() {
console.log("-----------------------info",this.$store.state.spokemanInfo) console.log("-----------------------info",this.$store.state.spokemanInfo)
this.checkedSubscribe = false;
this.getWxMiniSubscribeMessageConfig();
}, },
methods: { 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() { toOrderDetail() {
if (!this.render) return; if (!this.render) return;
console.log("查看详情"); console.log("查看详情");
...@@ -180,6 +208,46 @@ export default { ...@@ -180,6 +208,46 @@ export default {
url, 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() { toOrderList() {
let url = `/pages/index/main?from=home&backpath=${encodeURIComponent(`/order/orderList`)}` let url = `/pages/index/main?from=home&backpath=${encodeURIComponent(`/order/orderList`)}`
wx.redirectTo({ wx.redirectTo({
...@@ -272,7 +340,7 @@ export default { ...@@ -272,7 +340,7 @@ export default {
margin-top: 1px; margin-top: 1px;
overflow: hidden; overflow: hidden;
.paySuccess_detail { .paySuccess_detail {
padding: 0 63px; padding: 0 30px;
.iconPay { .iconPay {
margin: 0 auto; margin: 0 auto;
border-radius: 50%; border-radius: 50%;
...@@ -327,9 +395,9 @@ export default { ...@@ -327,9 +395,9 @@ export default {
} }
.bottom { .bottom {
margin-top: 10px; margin-top: 10px;
justify-content: space-around; justify-content: space-between;
/deep/.van-button { /deep/.van-button {
width: 118px; width: 140px;
height: 35px; height: 35px;
color: #929292; color: #929292;
line-height: 35px; line-height: 35px;
...@@ -342,6 +410,19 @@ export default { ...@@ -342,6 +410,19 @@ export default {
color: #fff; 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 { ...@@ -481,17 +481,6 @@ export default {
return JSON.stringify(pageData); return JSON.stringify(pageData);
}, },
toDingyue() {
wx.requestSubscribeMessage({
tmplIds: [
"cTgB0EMEibieOPU6HWPbmr3YCea7MZYCryxmi2_fS5o",
"pWi2-icKybK1fSSjRf-wrsQE1jmsuEp1QgPTAxn2nB0",
],
success(res) {
console.log(res, "-------------res");
},
});
},
}, },
}; };
</script> </script>
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
"usingComponents": { "usingComponents": {
"van-checkbox": "/static/vant/checkbox/index", "van-checkbox": "/static/vant/checkbox/index",
"van-popup":"/static/vant/popup/index", "van-popup":"/static/vant/popup/index",
"van-switch":"/static/vant/switch/index",
"van-button":"/static/vant/button/index", "van-button":"/static/vant/button/index",
"van-picker": "/static/vant/picker/index", "van-picker": "/static/vant/picker/index",
"van-icon":"/static/vant/icon/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