Skip to content

Commit

Permalink
订单支持周期性订阅
Browse files Browse the repository at this point in the history
  • Loading branch information
gooking committed Jul 22, 2021
1 parent ef69f52 commit 6132406
Show file tree
Hide file tree
Showing 6 changed files with 192 additions and 18 deletions.
2 changes: 1 addition & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ App({
wx.hideToast()
}
})
WXAPI.queryConfigBatch('mallName,WITHDRAW_MIN,ALLOW_SELF_COLLECTION,order_hx_uids,subscribe_ids,share_profile,adminUserIds,goodsDetailSkuShowType,shopMod,needIdCheck,balance_pay_pwd,shipping_address_gps,shipping_address_region_level,shopping_cart_vop_open,show_wx_quanzi,cps_open,recycle_open,categoryMod,hide_reputation,show_seller_number,show_goods_echarts,show_buy_dynamic,goods_search_show_type,show_3_seller,show_quan_exchange_score,show_score_exchange_growth,show_score_sign,fx_subscribe_ids,share_pic').then(res => {
WXAPI.queryConfigBatch('mallName,WITHDRAW_MIN,ALLOW_SELF_COLLECTION,order_hx_uids,subscribe_ids,share_profile,adminUserIds,goodsDetailSkuShowType,shopMod,needIdCheck,balance_pay_pwd,shipping_address_gps,shipping_address_region_level,shopping_cart_vop_open,show_wx_quanzi,cps_open,recycle_open,categoryMod,hide_reputation,show_seller_number,show_goods_echarts,show_buy_dynamic,goods_search_show_type,show_3_seller,show_quan_exchange_score,show_score_exchange_growth,show_score_sign,fx_subscribe_ids,share_pic,orderPeriod_open').then(res => {
if (res.code == 0) {
res.data.forEach(config => {
wx.setStorageSync(config.key, config.value);
Expand Down
4 changes: 2 additions & 2 deletions config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
version: '12.1.0',
note: '购物车区分多门店、多门店支持同时下单', // 这个为版本描述,无需修改
version: '12.2.0',
note: '订单支持周期性订阅', // 这个为版本描述,无需修改
subDomain: 'tz', // liu123 此处改成你自己的专属域名。什么是专属域名?请看教程 https://www.it120.cc/help/qr6l4m.html
merchantId: 951, // 商户ID,可在后台工厂设置-->商户信息查看
sdkAppID: 1400450467, // 腾讯实时音视频应用编号,请看教程 https://www.it120.cc/help/nxoqsl.html
Expand Down
4 changes: 3 additions & 1 deletion pages/select-address/index.wxml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<van-empty wx:if="{{ !addressList }}" description="暂无收货地址" />

<view class="list" wx:for="{{addressList}}" wx:key="id">
<van-cell border="{{ false }}" title="{{item.linkMan}} {{item.mobile}}" label="{{item.address}}" bind:click="selectTap" data-id="{{item.id}}" />
<view class="aaa">
<van-cell custom-class="aaa" title="{{item.linkMan}} {{item.mobile}}" label="{{item.address}}" bind:click="selectTap" data-id="{{item.id}}" />
</view>
<van-icon name="records" size="40rpx" bind:click="editAddess" data-id="{{item.id}}" />
</view>

Expand Down
3 changes: 3 additions & 0 deletions pages/select-address/index.wxss
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@
align-items: center;
padding-right: 32rpx;
border-bottom: solid 2rpx #eeeeee;
}
.aaa {
flex: 1;
}
95 changes: 92 additions & 3 deletions pages/to-pay-order/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,28 @@ const WXAPI = require('apifm-wxapi')
const AUTH = require('../../utils/auth')
const wxpay = require('../../utils/pay.js')

Date.prototype.format = function(format) {
var date = {
"M+": this.getMonth() + 1,
"d+": this.getDate(),
"h+": this.getHours(),
"m+": this.getMinutes(),
"s+": this.getSeconds(),
"q+": Math.floor((this.getMonth() + 3) / 3),
"S+": this.getMilliseconds()
};
if (/(y+)/i.test(format)) {
format = format.replace(RegExp.$1, (this.getFullYear() + '').substr(4 - RegExp.$1.length));
}
for (var k in date) {
if (new RegExp("(" + k + ")").test(format)) {
format = format.replace(RegExp.$1, RegExp.$1.length == 1
? date[k] : ("00" + date[k]).substr(("" + date[k]).length));
}
}
return format;
}

Page({
data: {
totalScoreToPay: 0,
Expand All @@ -29,7 +51,33 @@ Page({
bindMobileStatus: 0, // 0 未判断 1 已绑定手机号码 2 未绑定手机号码
userScore: 0, // 用户可用积分
deductionScore: '0', // 本次交易抵扣的积分数
shopCarType: 0 //0自营购物车,1云货架购物车
shopCarType: 0, //0自营购物车,1云货架购物车
dyopen: 0, // 是否开启订阅
dyunit: 0, // 按天
dyduration: 1, // 订阅间隔
dytimes: 1, // 订阅次数
dateStart: undefined, // 订阅首次扣费时间
minDate: new Date().getTime(),
maxDate: new Date(2030, 10, 1).getTime(),
currentDate: new Date().getTime(),
formatter: (type, value) => {
if (type === 'year') {
return `${value}年`;
}
if (type === 'month') {
return `${value}月`;
}
if (type === 'day') {
return `${value}日`;
}
if (type === 'hour') {
return `${value}点`;
}
if (type === 'minute') {
return `${value}分`;
}
return value;
},
},
onShow() {
if (this.data.pageIsEnd) {
Expand Down Expand Up @@ -91,8 +139,11 @@ Page({
},

onLoad(e) {
const nowDate = new Date();
let _data = {
isNeedLogistics: 1
isNeedLogistics: 1,
dateStart: nowDate.format('yyyy-MM-dd h:m:s'),
orderPeriod_open: wx.getStorageSync('orderPeriod_open')
}
if (e.orderType) {
_data.orderType = e.orderType
Expand Down Expand Up @@ -166,7 +217,17 @@ Page({
peisongType: this.data.peisongType,
deductionScore: this.data.deductionScore,
goodsType: this.data.shopCarType
};
}
if (this.data.dyopen == 1) {
const orderPeriod = {
unit: this.data.dyunit,
duration: this.data.dyduration,
dateStart: this.data.dateStart,
times: this.data.dytimes,
autoPay: true
}
postData.orderPeriod = JSON.stringify(orderPeriod)
}
if (this.data.kjId) {
postData.kjid = this.data.kjId
}
Expand Down Expand Up @@ -622,6 +683,16 @@ Page({
this.fetchShops()
}
},
dyChange(e) {
this.setData({
dyopen: e.detail.value
})
},
dyunitChange(e) {
this.setData({
dyunit: e.detail.value
})
},
cancelLogin() {
wx.navigateBack()
},
Expand Down Expand Up @@ -715,4 +786,22 @@ Page({
})
this.processYunfei()
},
dateStartclick(e) {
this.setData({
dateStartpop: true
})
},
dateStartconfirm(e) {
const d = new Date(e.detail)
this.setData({
dateStart: d.format('yyyy-MM-dd h:m:s'),
dateStartpop: false
})
console.log(e);
},
dateStartcancel(e) {
this.setData({
dateStartpop: false
})
}
})
102 changes: 91 additions & 11 deletions pages/to-pay-order/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -66,17 +66,18 @@
</block>
<view class="container-box cell-group">
<view class="peisong-way">
<view class="row-box" wx:if="{{shopCarType == 0 && isNeedLogistics > 0}}">
<view class="row-label">配送方式</view>
<radio-group bindchange="radioChange">
<label class="radio">
<radio value="kd" checked="{{peisongType == 'kd'}}" /> 快递
</label>
<label class="radio">
<radio value="zq" checked="{{peisongType == 'zq'}}" /> 到店自取
</label>
</radio-group>
</view>
<van-cell wx:if="{{shopCarType == 0 && isNeedLogistics > 0}}" title="配送方式">
<view slot="">
<radio-group bindchange="radioChange">
<label class="radio">
<radio value="kd" checked="{{peisongType == 'kd'}}" /> 快递
</label>
<label class="radio">
<radio value="zq" checked="{{peisongType == 'zq'}}" /> 到店自取
</label>
</radio-group>
</view>
</van-cell>
<van-cell wx:if="{{shopCarType == 1}}" title="配送地址" />
<picker wx:if="{{peisongType == 'zq' && shops}}" bindchange="shopSelect" value="{{shopIndex}}" range="{{shops}}" range-key="name">
<van-cell title="选择自提门店" value="{{shopIndex == -1 ? '请选择':shops[shopIndex].name}}" required is-link />
Expand Down Expand Up @@ -123,6 +124,70 @@
<input bindinput="remarkChange" type="text" class="liuyan" placeholder="如需备注请输入" />
</view>
</view>
<van-cell wx:if="{{ orderPeriod_open == 1 }}" title="订阅">
<view slot="">
<radio-group bindchange="dyChange">
<label class="radio">
<radio value="1" checked="{{ dyopen == 1 }}" /> 开启
</label>
<label class="radio">
<radio value="0" checked="{{ dyopen == 0 }}" /> 关闭
</label>
</radio-group>
</view>
</van-cell>
<van-cell wx:if="{{ dyopen == 1 }}" title="订阅周期">
<view slot="">
<radio-group bindchange="dyunitChange">
<label class="radio">
<radio value="0" checked="{{ dyunit == 0 }}" /> 天
</label>
<label class="radio">
<radio value="1" checked="{{ dyunit == 1 }}" /> 月
</label>
<label class="radio">
<radio value="2" checked="{{ dyunit == 2 }}" /> 年
</label>
</radio-group>
</view>
</van-cell>
<van-field
wx:if="{{ dyopen == 1 }}"
label="订阅间隔"
model:value="{{ dyduration }}"
type="number"
placeholder="请输入数字"
input-align="right"
use-button-slot
>
<view slot="button">
{{ dyunit == 0 ? '天': '' }}
{{ dyunit == 1 ? '月': '' }}
{{ dyunit == 2 ? '年': '' }}
</view>
</van-field>
<van-field
wx:if="{{ dyopen == 1 }}"
label="订阅次数"
model:value="{{ dytimes }}"
type="number"
placeholder="请输入数字"
input-align="right"
use-button-slot
>
<view slot="button">次</view>
</van-field>
<van-field
wx:if="{{ dyopen == 1 }}"
label="首次扣费"
is-link
readonly
value="{{ dateStart }}"
type="number"
placeholder="请输入数字"
input-align="right"
bind:click-input="dateStartclick"
/>
</view>
<view class="peisong-way" hidden="{{hasNoCoupons}}">
<view class="row-box" style="border-bottom:none;">
Expand Down Expand Up @@ -163,3 +228,18 @@
bind:submit="goCreateOrder"
/>
</block>

<van-popup
show="{{ dateStartpop }}"
position="bottom"
>
<van-datetime-picker
type="datetime"
value="{{ currentDate }}"
min-date="{{ minDate }}"
max-date="{{ maxDate }}"
formatter="{{ formatter }}"
bind:confirm="dateStartconfirm"
bind:cancel="dateStartcancel"
/>
</van-popup>

0 comments on commit 6132406

Please sign in to comment.