pipi 4 years ago
parent 1ea4d1e7ca
commit 4a78d7c532

@ -38,6 +38,7 @@
</template> </template>
<script> <script>
import {weixin} from '../../utils/weixin.js'
export default { export default {
data() { data() {
const currentDate = this.getDate({ const currentDate = this.getDate({
@ -49,12 +50,17 @@
token: '', token: '',
phone: '', phone: '',
productId: '', productId: '',
} },
token: '',
openid: '',
} }
}, },
onLoad() { onLoad() {
const phone_token = uni.getStorageSync('phone_token') const phone_token = uni.getStorageSync('phone_token')
this.info.phone = phone_token.phone this.info.phone = phone_token.phone
this.token = phone_token.token
let user_info = weixin.getUserInfoCache()
this.openid = user_info.openid
}, },
methods: { methods: {
pay() { pay() {
@ -68,7 +74,28 @@
} }
this.reqByToken('/api/member/order-add', this.info, r => { this.reqByToken('/api/member/order-add', this.info, r => {
console.log(r) uni.request({
url: this.baseUrl + '/api/member/order-payment',
method: 'GET',
data: {
token: this.token,
order_id: r.id,
openid: this.openid
},
success: res => {
let payParams = JSON.parse(res.data.jsApiParameters)
payParams.provider = 'wxpay'
payParams.success = result => {
uni.navigateTo({
url: '../active/active'
})
}
payParams.fail = result => {
console.log(result);
}
wx.requestPayment(payParams);
}
})
}) })
}, },
bindDateChange: function(e) { bindDateChange: function(e) {

Loading…
Cancel
Save