1. 增加购买物品时填写收件人的功能;
This commit is contained in:
parent
e8382f2774
commit
4e216409ae
@ -78,10 +78,12 @@ export default class extends wepy.app {
|
|||||||
onShow(options) {
|
onShow(options) {
|
||||||
console.log('app.onShow');
|
console.log('app.onShow');
|
||||||
console.log(options);
|
console.log(options);
|
||||||
|
if (options.scene === 1037) {
|
||||||
let params = options.query;
|
let params = options.query;
|
||||||
console.log(params.token);
|
|
||||||
this.globalData.gameToken = params.token;
|
this.globalData.gameToken = params.token;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
sleep (s) {
|
sleep (s) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
104
src/components/address-form.wpy
Normal file
104
src/components/address-form.wpy
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
<!--购买时填写收货-->
|
||||||
|
<style lang="less">
|
||||||
|
.form-bg{
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
background-color: #000000;
|
||||||
|
opacity: 0.6;
|
||||||
|
z-index: 101;
|
||||||
|
}
|
||||||
|
.address-form {
|
||||||
|
position: fixed;
|
||||||
|
top: 20%;
|
||||||
|
left: 0;
|
||||||
|
right: 0;
|
||||||
|
z-index: 102;
|
||||||
|
background-color: #F9F9F9;
|
||||||
|
}
|
||||||
|
.doc-title {
|
||||||
|
font-size: 25px;
|
||||||
|
line-height: 25px;
|
||||||
|
color: #666;
|
||||||
|
padding: 15px 0;
|
||||||
|
margin: 20px 15px;
|
||||||
|
border-bottom: 1rpx solid #e5e5e5;
|
||||||
|
}
|
||||||
|
.form-action-bar {
|
||||||
|
margin-top: 20rpx;
|
||||||
|
padding: 10rpx;
|
||||||
|
}
|
||||||
|
.btn-white {
|
||||||
|
background-color: #fff;
|
||||||
|
}
|
||||||
|
.zan-btn {
|
||||||
|
border: 1rpx solid #e5e5e5;
|
||||||
|
margin-bottom: 8rpx;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<template>
|
||||||
|
<view class="form-bg {{ config.hide ? 'hidden' : ''}}" ></view>
|
||||||
|
<view class="address-form {{ config.hide ? 'hidden' : ''}}">
|
||||||
|
<view class="doc-title">填写收件人信息</view>
|
||||||
|
<view class="zan-form ">
|
||||||
|
<view class="zan-cell zan-form__item">
|
||||||
|
<text class="zan-form__title">收货人</text>
|
||||||
|
<input class="zan-form__input zan-cell__bd" placeholder="名字" @change="nameChange" value="{{addressInfo.name}}"/>
|
||||||
|
</view>
|
||||||
|
<view class="zan-cell zan-form__item">
|
||||||
|
<text class="zan-form__title">联系电话</text>
|
||||||
|
<input class="zan-form__input zan-cell__bd" type="number" maxlength="12" @change="mobileChange" value="{{addressInfo.mobile}}" placeholder="手机或固定电话" />
|
||||||
|
</view>
|
||||||
|
<view class="zan-cell zan-form__item">
|
||||||
|
<text class="zan-form__title">收货地址</text>
|
||||||
|
<input class="zan-form__input zan-cell__bd" type="text" maxlength="200" @change="addressChange" value="{{addressInfo.address}}" placeholder="收货地址" />
|
||||||
|
</view>
|
||||||
|
<view class="form-action-bar">
|
||||||
|
<button class="zan-btn zan-btn--large zan-btn--primary" @tap="confirmTap">确认付款</button>
|
||||||
|
<button class="zan-btn zan-btn--large btn-white" @tap="cancelTap">取消</button>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
|
||||||
|
</view>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
import wepy from 'wepy'
|
||||||
|
|
||||||
|
export default class addressForm extends wepy.component {
|
||||||
|
props = {
|
||||||
|
config: {
|
||||||
|
hide: true
|
||||||
|
},
|
||||||
|
addressInfo: {
|
||||||
|
mobile: '',
|
||||||
|
name: '',
|
||||||
|
address: ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
data = {
|
||||||
|
}
|
||||||
|
methods = {
|
||||||
|
cancelTap(e) {
|
||||||
|
this.$emit('cancelTap')
|
||||||
|
},
|
||||||
|
confirmTap(e) {
|
||||||
|
this.$emit('confirmTap', this.addressInfo);
|
||||||
|
},
|
||||||
|
nameChange(e) {
|
||||||
|
this.addressInfo.name = e.detail.value;
|
||||||
|
this.$apply()
|
||||||
|
},
|
||||||
|
mobileChange(e) {
|
||||||
|
this.addressInfo.mobile = e.detail.value;
|
||||||
|
this.$apply()
|
||||||
|
},
|
||||||
|
addressChange(e) {
|
||||||
|
this.addressInfo.address = e.detail.value;
|
||||||
|
this.$apply()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
@ -86,8 +86,11 @@
|
|||||||
},
|
},
|
||||||
bottomSecondTap(e) {
|
bottomSecondTap(e) {
|
||||||
console.log('bottomSecondTap');
|
console.log('bottomSecondTap');
|
||||||
|
let self = this;
|
||||||
wepy.navigateBackMiniProgram({
|
wepy.navigateBackMiniProgram({
|
||||||
extraData: {
|
extraData: {
|
||||||
|
type: self.currentType,
|
||||||
|
event_type: 'pay_result',
|
||||||
success: false
|
success: false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -143,15 +146,17 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
async queryOrder() {
|
async queryOrder() {
|
||||||
|
let self = this;
|
||||||
try {
|
try {
|
||||||
let res = await http.post('/api/emulated/query_order', {tid: this.tid});
|
let res = await http.post('/api/emulated/query_order', {tid: this.tid});
|
||||||
if (res.errcode === 0 && res.result === 1) {
|
if (res.errcode === 0 && res.result === 1) {
|
||||||
wepy.showToast({
|
wepy.navigateBackMiniProgram({
|
||||||
title: '支付成功',
|
extraData: {
|
||||||
icon: 'none',
|
type: self.currentType,
|
||||||
duration: 2000
|
event_type: 'pay_result',
|
||||||
|
success: true
|
||||||
|
}
|
||||||
})
|
})
|
||||||
jcEvent.emit(jcEvent.events.NEED_UPDATE_SCORE, {});
|
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
|
@ -7,18 +7,21 @@
|
|||||||
<view class="container">
|
<view class="container">
|
||||||
<image class="product_img" mode="widthFix" src="https://resource.kingsome.cn/voodoo/5c788d47486f49165aa057b6.jpeg"/>
|
<image class="product_img" mode="widthFix" src="https://resource.kingsome.cn/voodoo/5c788d47486f49165aa057b6.jpeg"/>
|
||||||
</view>
|
</view>
|
||||||
|
<addressFrom :config.sync="formCfg" :addressInfo.sync="addressInfo" @cancelTap.user="formCancel" @confirmTap.user="formConfirm"/>
|
||||||
<gameBottomBar :config.sync="bottomActionCfg" @bottomMainTap.user="bottomMainTap"
|
<gameBottomBar :config.sync="bottomActionCfg" @bottomMainTap.user="bottomMainTap"
|
||||||
@bottomSecondTap.user="bottomSecondTap"/>
|
@bottomSecondTap.user="bottomSecondTap"/>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
import wepy from 'wepy';
|
import wepy from 'wepy';
|
||||||
import gameBottomBar from '../components/game-bottom-bar';
|
import gameBottomBar from '../components/game-bottom-bar';
|
||||||
|
import addressFrom from '../components/address-form';
|
||||||
import http from '../utils/http';
|
import http from '../utils/http';
|
||||||
import jcEvent from '../common/jc-event';
|
import jcEvent from '../common/jc-event';
|
||||||
|
|
||||||
export default class ProductPage extends wepy.page {
|
export default class ProductPage extends wepy.page {
|
||||||
components = {
|
components = {
|
||||||
gameBottomBar: gameBottomBar
|
gameBottomBar: gameBottomBar,
|
||||||
|
addressFrom: addressFrom
|
||||||
};
|
};
|
||||||
config = {
|
config = {
|
||||||
navigationBarTitleText: '购买产品'
|
navigationBarTitleText: '购买产品'
|
||||||
@ -32,15 +35,89 @@
|
|||||||
secondBtnIconClass: 'icon-forbid',
|
secondBtnIconClass: 'icon-forbid',
|
||||||
secondBtnTitle: '取消'
|
secondBtnTitle: '取消'
|
||||||
},
|
},
|
||||||
|
formCfg: {
|
||||||
|
hide: true
|
||||||
|
},
|
||||||
|
addressInfo: {
|
||||||
|
mobile: '',
|
||||||
|
name: '',
|
||||||
|
address: ''
|
||||||
|
},
|
||||||
tid: ''
|
tid: ''
|
||||||
};
|
};
|
||||||
methods = {
|
methods = {
|
||||||
bottomMainTap(e) {
|
bottomMainTap(e) {
|
||||||
console.log('bottomMainTap');
|
console.log('bottomMainTap');
|
||||||
|
this.showBuyMenu();
|
||||||
|
},
|
||||||
|
bottomSecondTap(e) {
|
||||||
|
console.log('bottomSecondTap');
|
||||||
|
wepy.navigateBackMiniProgram({
|
||||||
|
extraData: {
|
||||||
|
event_type: 'pay_result',
|
||||||
|
type: 'item',
|
||||||
|
success: false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
},
|
||||||
|
async formConfirm(data) {
|
||||||
|
this.addressInfo = data;
|
||||||
|
try {
|
||||||
|
await this.updateUserInfo();
|
||||||
|
this.buy();
|
||||||
|
} catch (err) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
formCancel() {
|
||||||
|
this.formCfg.hide = true;
|
||||||
|
this.$apply();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
onLoad(params) {
|
||||||
|
this.gid = decodeURIComponent(params.gid);
|
||||||
|
this.getUserInfo();
|
||||||
|
}
|
||||||
|
async showBuyMenu() {
|
||||||
|
let self = this;
|
||||||
|
try {
|
||||||
|
let res = await wepy.showActionSheet({
|
||||||
|
itemList: ['到店自取', '快递']
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!res.cancel) {
|
||||||
|
if (res.tapIndex === 0) {
|
||||||
|
self.buy();
|
||||||
|
} else {
|
||||||
|
self.showAddressForm();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.log('cancel select')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async getUserInfo() {
|
||||||
|
try {
|
||||||
|
let res = await http.post('/api/emulated/user_info', {type: 'all'});
|
||||||
|
console.log(res);
|
||||||
|
if (res.userInfo) {
|
||||||
|
this.addressInfo = res.userInfo.address_info || {mobile: '', name: '', address: ''};
|
||||||
|
}
|
||||||
|
this.$apply();
|
||||||
|
} catch (err) {
|
||||||
|
console.log('error get user info');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
updateUserInfo() {
|
||||||
|
return http.post('/api/emulated/update_user_info', this.addressInfo);
|
||||||
|
}
|
||||||
|
buy() {
|
||||||
let self = this;
|
let self = this;
|
||||||
wepy.showLoading({
|
wepy.showLoading({
|
||||||
title: '支付中'
|
title: '支付中'
|
||||||
})
|
});
|
||||||
http.post('/api/emulated/pre_pay', { gid: this.gid })
|
http.post('/api/emulated/pre_pay', { gid: this.gid })
|
||||||
.then(res => {
|
.then(res => {
|
||||||
console.log(res.data);
|
console.log(res.data);
|
||||||
@ -80,34 +157,27 @@
|
|||||||
.catch(err => {
|
.catch(err => {
|
||||||
console.log('err update game history');
|
console.log('err update game history');
|
||||||
});
|
});
|
||||||
},
|
|
||||||
bottomSecondTap(e) {
|
|
||||||
console.log('bottomSecondTap');
|
|
||||||
wepy.navigateBackMiniProgram({
|
|
||||||
extraData: {
|
|
||||||
success: false
|
|
||||||
}
|
}
|
||||||
})
|
showAddressForm() {
|
||||||
}
|
this.formCfg.hide = false;
|
||||||
};
|
this.$apply();
|
||||||
|
|
||||||
onLoad(params) {
|
|
||||||
this.gid = decodeURIComponent(params.gid);
|
|
||||||
console.log('product onload');
|
|
||||||
console.log('gid: ' + this.gid);
|
|
||||||
}
|
}
|
||||||
async queryOrder() {
|
async queryOrder() {
|
||||||
try {
|
try {
|
||||||
|
let self = this;
|
||||||
let res = await http.post('/api/emulated/query_order', {tid: this.tid});
|
let res = await http.post('/api/emulated/query_order', {tid: this.tid});
|
||||||
if (res.errcode === 0 && res.result === 1) {
|
if (res.errcode === 0 && res.result === 1) {
|
||||||
wepy.showToast({
|
// wepy.showToast({
|
||||||
title: '支付成功',
|
// title: '支付成功',
|
||||||
icon: 'none',
|
// icon: 'none',
|
||||||
duration: 2000
|
// duration: 2000
|
||||||
})
|
// })
|
||||||
wepy.navigateBackMiniProgram({
|
wepy.navigateBackMiniProgram({
|
||||||
extraData: {
|
extraData: {
|
||||||
success: true
|
type: 'item',
|
||||||
|
event_type: 'pay_result',
|
||||||
|
success: true,
|
||||||
|
gid: self.gid
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user