Commit cacf36db by 程南

订阅消息

parent 3f732f13
......@@ -19,9 +19,9 @@ wxService.page({
trolleySku2Buy: Array,
currentOrderList: Array,
isSelect: false,
selectPrice:'',
noSelectPrice:'',
plusSpread:'',
selectPrice: '',
noSelectPrice: '',
plusSpread: '',
goodsAddress: false,
citys: null,
cityView: '',
......@@ -36,16 +36,16 @@ wxService.page({
defalutCoupon: '',
defalutCouponId: '', // 默认第一项
addressId: '', // 收货地址id
totalGoodsPrice : 0,
buyerRemark : '',//备注信息
totalGoodsPrice: 0,
buyerRemark: '',//备注信息
currentType: 'delivery',//delivery 快递 selfPickUp 门店自提
storeInfo : {
storeName : '',
storeId : '',
storeAddress : '',
storeCode : ''
storeInfo: {
storeName: '',
storeId: '',
storeAddress: '',
storeCode: ''
},
orderStoreInfo : null,
orderStoreInfo: null,
},
/**
......@@ -54,7 +54,6 @@ wxService.page({
onLoad: function (options) {
wx.hideShareMenu();
this.getMyLocationInfo();
console.log(this.data)
},
////获取位置信息并获取附近门店信息
getMyLocationInfo(cb) {
......@@ -65,7 +64,7 @@ wxService.page({
//获取本地缓存的地址信息
let myLocation = wx.getStorageSync('myLocation') ? wx.getStorageSync('myLocation') : null;
if (!myLocation){
if (!myLocation) {
wx.getLocation({
type: 'wgs84',
success(res) {
......@@ -80,15 +79,15 @@ wxService.page({
}
});
return ;
return;
}
this.getMyStoreInfoByPosition(myLocation.latitude,myLocation.longitude);
this.getMyStoreInfoByPosition(myLocation.latitude, myLocation.longitude);
},
//获取附近门店信息
getMyStoreInfoByPosition(latitude, longitude){
getMyStoreInfoByPosition(latitude, longitude) {
wxService.post(`/sale/trade/buyer/getMemberStore?latitude=${latitude}&longitude=${longitude}`).then(res => {
if (res){
if (res) {
if (res.data.result == 0) {
let obj = res.data.data ? res.data.data : null;
if (obj) {
......@@ -118,10 +117,10 @@ wxService.page({
}, () => {
this.initCitys()
// 地址列表
if (this.data.currentType == 'delivery'){
if (this.data.currentType == 'delivery') {
this.getAddressList()
}
else{
else {
// 获取本地选择的门店信息
this.getLocalStoreInfo();
}
......@@ -132,7 +131,7 @@ wxService.page({
},
//获取备注信息
getLocalRemarkInfo(){
getLocalRemarkInfo() {
this.data.buyerRemark = wx.getStorageSync('orderRemark');
this.setData({
buyerRemark: this.data.buyerRemark
......@@ -140,32 +139,32 @@ wxService.page({
},
//输入备注
onTapInputRemark(){
onTapInputRemark() {
wx.navigateTo({
url: '/pages/remark/remark',
});
},
onUnload(){
onUnload() {
wx.removeStorageSync('orderRemark');
wx.removeStorageSync('choosedStoreInfo');
},
//获取本地选择的门店信息
getLocalStoreInfo(){
getLocalStoreInfo() {
let storeInfo = wx.getStorageSync('choosedStoreInfo') ? wx.getStorageSync('choosedStoreInfo') : null;
if (storeInfo){
if (storeInfo) {
this.data.storeInfo.storeId = storeInfo.id;
this.data.storeInfo.storeName = storeInfo.name;
this.data.storeInfo.storeAddress = storeInfo.storeFullAddress;
this.data.storeInfo.storeCode = storeInfo.code;
}
else{
else {
this.data.storeInfo = {
storeName: '',
storeId : '',
storeAddress : '',
storeCode : '',
storeId: '',
storeAddress: '',
storeCode: '',
}
}
......@@ -182,27 +181,27 @@ wxService.page({
},
//切换tab
onTapChangeType(e){
onTapChangeType(e) {
let type = e.currentTarget.dataset.type;
this.setData({
currentType : type
currentType: type
});
if (type == 'delivery'){
if (type == 'delivery') {
this.getAddressList()
}
else{
else {
this.getLocalStoreInfo();
}
},
//选择门店去
onTapSelectStore(){
onTapSelectStore() {
wx.navigateTo({
url: '/subPackage/page/pages/chooseStore/chooseStore?isFrom=order',
});
},
//订单备注输入
onBuyerRemarkInput(e){
onBuyerRemarkInput(e) {
this.data.buyerRemark = e.detail.value;
this.setData({
buyerRemark: this.data.buyerRemark
......@@ -211,19 +210,19 @@ wxService.page({
// select 传过来
updateCoupon(e) {
// faceAmount 抵用多少钱(分) 1 抵用券 2 折扣券
if(!e.detail) {
if (!e.detail) {
this.setData({
defalutCoupon: 0,
couponId: '',
couponSettingId: '',
defalutCouponId: '',
currentCoupon : 0,
},() => {
currentCoupon: 0,
}, () => {
this.setPayPrice();
});
return
}
const { faceAmount, type, id, couponDiscount,sid } = e.detail
const { faceAmount, type, id, couponDiscount, sid } = e.detail
const { defalutCouponId } = this.data
const { orderPrice } = this.data
// couponId---id couponSettingId --sid
......@@ -233,7 +232,7 @@ wxService.page({
this.setData({
defalutCoupon: true,
defalutCouponId: finCouponId ? '' : defalutCouponId,
[finCouponName] : finCouponId,
[finCouponName]: finCouponId,
// couponId: id,
haveCoupon: true,
currentCoupon: `${faceAmount / 100} 元`
......@@ -243,7 +242,7 @@ wxService.page({
// let spread = Math.round(orderPrice - discounPrice)
this.setData({
defalutCoupon: true,
[finCouponName] : finCouponId,
[finCouponName]: finCouponId,
defalutCouponId: finCouponId ? '' : defalutCouponId,
// couponId: id,
haveCoupon: true,
......@@ -271,30 +270,30 @@ wxService.page({
//提交按钮
formSubmit(e) {
//判断是不是开卡了
if (this.data.orderingMustOpenCard){
if (this.data.orderingMustOpenCard) {
let baseInfo = wx.getStorageSync('_baseUserInfo');
if(!baseInfo){
if (!baseInfo) {
wx.showToast({
title: '你还未登录,请先去登录',
icon: 'none'
});
return ;
return;
}
let memberActivateStatus = baseInfo.memberActivateStatus;
if (!memberActivateStatus){
if (!memberActivateStatus) {
wx.showModal({
title: '下单开卡提示',
content: '对不起,需要您先开卡后才能下单,点击确定去开卡',
showCancel : true,
confirmText : '确定',
showCancel: true,
confirmText: '确定',
confirmColor: '#cb3c3c',
success: function (res){
if (res.confirm){
success: function (res) {
if (res.confirm) {
//跳去开卡
wxService.openCard();
}
else if (res.cancel){
else if (res.cancel) {
}
}
......@@ -304,7 +303,7 @@ wxService.page({
}
}
//判断是不是快递配送
if (this.data.currentType == 'delivery'){
if (this.data.currentType == 'delivery') {
const { goodsAddress } = this.data
// 保存地址 && 支付
if (goodsAddress) {
......@@ -379,7 +378,7 @@ wxService.page({
this.handelGobuy()
}
}
else{
else {
this.handelGobuy()
}
},
......@@ -498,7 +497,7 @@ wxService.page({
params.addressId = addressId ? addressId : addressInfo.id // 微信地址 or 地址id
params.orderType = 1;
}
else{
else {
params.orderType = 4;
params.storeId = this.data.storeInfo.storeId;
}
......@@ -548,7 +547,7 @@ wxService.page({
let skuList = data.tradePreviewSkus
let sum = 0
skuList.forEach((item,index) => {
skuList.forEach((item, index) => {
// item.price
sum += skuList[index].price * skuList[index].count;
});
......@@ -557,7 +556,7 @@ wxService.page({
// 初始化商品价格
const { isSelect } = this.data
if(isSelect){
if (isSelect) {
this.setData({
selectPrice: sum
})
......@@ -579,7 +578,7 @@ wxService.page({
let couponSettingId = data && data.couponDiscountPreviews.length &&
data.couponDiscountPreviews[0] && data.couponDiscountPreviews[0].couponDTOS[0] &&
data.couponDiscountPreviews[0].couponDTOS[0].couponSettingId || '';
data.couponDiscountPreviews = data.couponDiscountPreviews ? data.couponDiscountPreviews :[];
data.couponDiscountPreviews = data.couponDiscountPreviews ? data.couponDiscountPreviews : [];
// id / couponSettingId
this.setData({
currentOrderList: data,
......@@ -607,18 +606,18 @@ wxService.page({
couponSettingId,
addressId,
addressInfo,
defalutCouponId ,
defalutCouponId,
} = this.data;
let finCouponName,finCouponId
if(!defalutCoupon) {
let finCouponName, finCouponId
if (!defalutCoupon) {
finCouponName = 'couponId'
finCouponId = ''
} else {
// 当前选中 哪一个id couponSettingId
// 默认券存在 id settingId
let currentCouponId // couponId / 第一项 id
if(defalutCouponId) {
if (defalutCouponId) {
finCouponId = defalutCouponId
finCouponName = 'couponId'
} else {
......@@ -632,11 +631,11 @@ wxService.page({
[finCouponName]: finCouponId,
// couponId: couponId? couponId : defalutCouponId,
trolleySku2Buy,
buyerRemark : this.data.buyerRemark,
buyerRemark: this.data.buyerRemark,
}
//判断是快递下单还是自提下单
if (this.data.currentType == 'delivery'){
if (this.data.currentType == 'delivery') {
params.orderType = 1;
params.addressId = addressId ? addressId : addressInfo.id // 微信地址 or 地址id
......@@ -649,12 +648,12 @@ wxService.page({
return;
}
}
else{
else {
params.orderType = 4;
params.storeId = this.data.storeInfo.storeId;
params.storeCode = this.data.storeInfo.storeCode;
params.storeName = this.data.storeInfo.storeName;
if (!params.storeId){
if (!params.storeId) {
wx.showToast({
title: '门店自提需要选择门店',
icon: 'none'
......@@ -672,39 +671,39 @@ wxService.page({
title: '正在下单..'
});
const { isSelect} = this.data;
const { isSelect } = this.data;
//增加订单备注信息
params.buyerRemark = this.data.buyerRemark;
//下单之前先做校验
this.checkOrder(params).then(result => {
if (result){
if (result) {
let data = result.data.data ? result.data.data : [];
if(data.length == 0){
this.order(isSelect,params);
if (data.length == 0) {
this.order(isSelect, params);
}
else{
else {
//有商品限购了,组织提示语
let tips = '根据限购规则以下商品限购:\r\n';
let tempObj = data[0];
//每人限购
if (tempObj.limitType == 1){
if (tempObj.limitType == 1) {
tips = `商品"${tempObj.productName}"每人限购${tempObj.limitNum}件`;
}
//每次限购
else if (tempObj.limitType == 2){
else if (tempObj.limitType == 2) {
tips = `商品"${tempObj.productName}"每次限购${tempObj.limitNum}件`;
}
wx.showModal({
title: '商品限购提醒',
content: tips,
confirmText : '好的',
confirmText: '好的',
confirmColor: '#cb3c3c',
showCancel: false,
success(confirm){
if (confirm.confirm){
success(confirm) {
if (confirm.confirm) {
wx.navigateBack({
delta : 1
delta: 1
});
}
},
......@@ -714,12 +713,13 @@ wxService.page({
});
},
//下单
order(isSelect,params){
if(this.data.orderStoreInfo){
if (this.data.orderStoreInfo.storeId){
order(isSelect, params) {
if (this.data.orderStoreInfo) {
if (this.data.orderStoreInfo.storeId) {
params.storeId = this.data.orderStoreInfo.storeId;
}
if (this.data.orderStoreInfo.storeInfo){
if (this.data.orderStoreInfo.storeInfo) {
params.storeInfo = this.data.orderStoreInfo.storeInfo;
}
}
......@@ -729,6 +729,7 @@ wxService.page({
wxService.post(`${url}`, params).then(res => {
if (res) {
const { result, data } = res.data
let tradeId = data.tradeId;
wx.removeStorageSync('choosedStoreInfo');
wx.removeStorageSync('orderRemark');
if (result == 0) {
......@@ -738,15 +739,42 @@ wxService.page({
success(res) {
wx.hideLoading()
// 支付成功页面
let baseUserInfo = wx.getStorageSync('_baseUserInfo');
wxService.post(`${'/merchant/message/wxSubMsgMapping/getListByParams'}`, {
scenarioIds: ['ordersend', 'ordersign'],
sourceFrom: 2,
switchType: 3
}).then(res => {
let tempArr = res.data.data;
let tempids = [];
tempArr.map(item => {
tempids.push(item.templateId);
})
wx.requestSubscribeMessage({
tmplIds: tempids,
success: (res)=>{
for(let i = 0; i < tempArr.length; i++){
wxService.post(`${'/merchant/message/wxSubMsgSubscride/member/subscribe'}`, {
businessId: tradeId,
memberId: baseUserInfo.memberId,
scenarioId:tempArr[i].scenarioId,
templateId: tempArr[i].templateId
}).then(resp => { })
}
},
complete: (res)=>{
wx.redirectTo({
url: `/subPackage/page/pages/paymentStatus/paymentStatus?status=S&amount=${amount}&type=${_this.data.currentType}`,
});
}
})
})
},
fail(res) {
wx.hideLoading();
wx.showToast({
title: '支付已取消',
icon : 'none'
icon: 'none'
});
if (_this.data.currentType == 'delivery') {
wx.redirectTo({
......@@ -765,14 +793,14 @@ wxService.page({
});
},
//校验订单中商品限购情况
checkOrder(params){
return wxService.post(`/sale/trade/buyer/bill/before/check`,params);
checkOrder(params) {
return wxService.post(`/sale/trade/buyer/bill/before/check`, params);
},
// 获取地址列表
getAddressList() {
const { memberId } = wx.getStorageSync('_baseUserInfo');
const { trolleySku2Buy, checkByPremium } = this.data;
let params = {checkByPremium, trolleySku2Buy};
let params = { checkByPremium, trolleySku2Buy };
params.orderType = 1;
wxService.post(`/member/addressManage/getall`, {
......@@ -783,7 +811,7 @@ wxService.page({
let { result, data } = res.data
if (result == 0) {
//看看本地是不是有已经选择的地址了
if (!hasDefalut){ // 无
if (!hasDefalut) { // 无
//看一下地址列表中是不是有默认地址
let defaultInAddressList = null;
data = data ? data : [];
......@@ -794,7 +822,7 @@ wxService.page({
}
});
if (defaultInAddressList){
if (defaultInAddressList) {
this.data.addressId = defaultInAddressList ? defaultInAddressList.id : '';
this.data.addressInfo = defaultInAddressList;
params.addressId = this.data.addressId;
......@@ -806,7 +834,7 @@ wxService.page({
goodsAddress: params.addressId ? false : true,
});
}
else{ // 有已经选择的地址了
else { // 有已经选择的地址了
let defaultInAddressList = null;
//判断地址列表中是不是已经把这个地址删除了
let id = hasDefalut.id;
......@@ -814,7 +842,7 @@ wxService.page({
if (filterArr.length > 0) {
defaultInAddressList = hasDefalut
}
else{ // 无
else { // 无
//此时已经没有 看看是不是有默认地址 有则默认选中
data = data ? data : [];
data.forEach(item => {
......@@ -840,7 +868,7 @@ wxService.page({
this.calPreferentialPrice(params)
}
}).finally(() => {});
}).finally(() => { });
},
//获取微信地址
chooseWxAddress() {
......@@ -879,7 +907,7 @@ wxService.page({
this.setData({
addressId: data,
goodsAddress: true,
},() => {
}, () => {
this.getAddressList();
})
}
......
......@@ -10,7 +10,7 @@
data-type="selfPickUp" bindtap="onTapChangeType">门店自提</view>
</view>
<form bindsubmit="formSubmit">
<form>
<!-- 快递地址 -->
<view class="address-wrap" wx:if="{{currentType == 'delivery'}}">
<block wx:if="{{goodsAddress}}">
......@@ -244,7 +244,7 @@
<text class="cost-label">实付款:</text>
<text class="cost-price">¥{{utils.numberFormat(orderPrice)}}</text>
</view>
<button form-type="submit" class="theme-color">立即购买</button>
<button bind:tap="formSubmit" class="theme-color">立即购买</button>
</view>
</form>
</view>
......
......@@ -6,9 +6,6 @@ const envInfo = require('../../config/index').envInfo
wxService.page({
/**
* 页面的初始数据
*/
data: {
imageDomain: '',
refundCreateDto: {
......@@ -49,8 +46,8 @@ wxService.page({
}
let skulist = [];
selectGoods.forEach(item=>{
const {skuId,count} = item;
selectGoods.forEach(item => {
const { skuId, count } = item;
skulist.push({
skuId,
count
......@@ -59,7 +56,7 @@ wxService.page({
this.reFundPreview({
tradeId: this.data.id,
skuList:skulist
skuList: skulist
})
var refundCreateDto = this.data.refundCreateDto
......@@ -77,6 +74,7 @@ wxService.page({
},
//创建退款
handelRequestRefund(params) {
let _self = this;
wx.showLoading({
title: '加载中',
mask: true
......@@ -86,6 +84,31 @@ wxService.page({
const { result, data } = res.data
if (result == 0) {
wx.hideLoading()
let baseUserInfo = wx.getStorageSync('_baseUserInfo');
wxService.post(`${'/merchant/message/wxSubMsgMapping/getListByParams'}`, {
scenarioIds: ['orderrefundfinsh', 'orderrefundcheck'],
sourceFrom: 2,
switchType: 3
}).then(res => {
let tempArr = res.data.data;
let tempids = [];
tempArr.map(item => {
tempids.push(item.templateId);
})
wx.requestSubscribeMessage({
tmplIds: tempids,
success: (res)=>{
for(let i = 0; i < tempArr.length; i++){
wxService.post(`${'/merchant/message/wxSubMsgSubscride/member/subscribe'}`, {
businessId: _self.data.id,
memberId: baseUserInfo.memberId,
scenarioId:tempArr[i].scenarioId,
templateId: tempArr[i].templateId
}).then(resp => { })
}
},
complete: (res)=>{
wx.showToast({
title: '申请退款成功',
});
......@@ -93,10 +116,18 @@ wxService.page({
setTimeout(() => {
// wxService.router(`/pages/order/order`).search({params})
wx.navigateBack({
delta : 1
delta: 1
});
}, 2000)
}
})
})
}
}
})
......@@ -115,8 +146,8 @@ wxService.page({
wx.hideLoading()
let newReasonList = [];
data.forEach((item,index)=>{
const {reason} = item;
data.forEach((item, index) => {
const { reason } = item;
newReasonList.push({
name: reason,
value: index + 1
......@@ -149,7 +180,7 @@ wxService.page({
}
this.setData({
cartList
},()=>{
}, () => {
this.getReturnPrice()
})
},
......@@ -190,15 +221,15 @@ wxService.page({
var index = e.currentTarget.dataset.index
var cartList = this.data.cartList
var proNum = cartList[index].count;
if (proNum < cartList[index].canRefundNum){
if (proNum < cartList[index].canRefundNum) {
proNum++
}
else{
else {
wx.showToast({
title: '退单数量不能大于当前商品购买数量',
icon : 'none'
icon: 'none'
});
return ;
return;
}
cartList[index].count = proNum
......@@ -235,9 +266,9 @@ wxService.page({
this.editOk(cartList[index]) //调用完成
})
},
editOk(cartPro){
editOk(cartPro) {
let skulist = [];
const {skuId,count} = cartPro;
const { skuId, count } = cartPro;
skulist.push({
skuId,
count
......@@ -245,7 +276,8 @@ wxService.page({
this.reFundPreview({
tradeId: this.data.id,
skuList:skulist}) // 退款预览
skuList: skulist
}) // 退款预览
},
getReturnPrice() {
var cartList = this.data.cartList
......@@ -260,7 +292,7 @@ wxService.page({
let tempPrice = parseInt(returnPrice * 100);
this.setData({
returnOrder: parseFloat(tempPrice/100).toFixed(2)
returnOrder: parseFloat(tempPrice / 100).toFixed(2)
})
},
......@@ -276,7 +308,7 @@ wxService.page({
detail.skuVOList.forEach(item => {
item.checked = false;
let paySkuPrice = parseInt(item.amount * 100 / item.totalCount);
item.paySkuPrice = (paySkuPrice/100).toFixed(2);
item.paySkuPrice = (paySkuPrice / 100).toFixed(2);
});
this.setData({
......@@ -304,13 +336,13 @@ wxService.page({
},
//退款prever
reFundPreview(cartPro={}) {
const params = {...cartPro}
reFundPreview(cartPro = {}) {
const params = { ...cartPro }
wx.showLoading({
title: '加载中',
mask: true
})
wxService.post(`/sale/refund/buyer/preview`,params).then(res => {
wxService.post(`/sale/refund/buyer/preview`, params).then(res => {
if (res) {
const { result, data } = res.data
if (result == 0) {
......
......@@ -43,7 +43,7 @@
"list": []
},
"miniprogram": {
"current": 80,
"current": -1,
"list": [
{
"id": -1,
......@@ -149,7 +149,7 @@
"id": 16,
"name": "商品详情页",
"pathName": "pages/productDetail/productDetail",
"query": "id=686861371018723328",
"query": "id=647096699302580224",
"scene": null
},
{
......
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