order_payment.js 2.99 KB
   1
   2
   3
   4
   5
   6
   7
   8
   9
  10
  11
  12
  13
  14
  15
  16
  17
  18
  19
  20
  21
  22
  23
  24
  25
  26
  27
  28
  29
  30
  31
  32
  33
  34
  35
  36
  37
  38
  39
  40
  41
  42
  43
  44
  45
  46
  47
  48
  49
  50
  51
  52
  53
  54
  55
  56
  57
  58
  59
  60
  61
  62
  63
  64
  65
  66
  67
  68
  69
  70
  71
  72
  73
  74
  75
  76
  77
  78
  79
  80
  81
  82
  83
  84
  85
  86
  87
  88
  89
  90
  91
  92
  93
  94
  95
  96
  97
  98
  99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
//articleLists.js 文章列表
// 网络请求工具类
var networkUtil = require('../../utils/network_util.js')
var api = require('../../utils/apiFile.js')
// 事件监听
var event = require('../../utils/event.js')
var util = require('../../utils/util.js')

// 获取应用实例
var app = getApp()
Page({
data: {
orderId:'',
OriginalorderId: '',
orderTime:'',
realPrice:'',
orderName:'',
orderContent: '',
orderIcon:''
},
onLoad: function (options) {
networkUtil.showLoading()
var content = []
var checked = {
"hId": app.globalData.userInfo.hospitalId,
"goodId": options.id
}
content.push(checked)
this.getOrderDetail(content)
},
getOrderDetail(content){
var self = this
var param = JSON.stringify(content)
networkUtil._post(api.order, { param: param }, function (res) {

console.log(res)
if (res.data.goodsOrderId.length>27){
self.setData({
orderId: res.data.goodsOrderId.slice(0,27),
})
}else{
self.setData({
orderId: res.data.goodsOrderId,
})
}
self.setData({
OriginalorderId: res.data.goodsOrderId,
orderTime: res.data.now,
realPrice: res.data.realPrice,
orderName: res.data.data[0].goodName,
orderContent: res.data.data[0].desc,
orderIcon: res.data.data[0].icon,
})
}, function (res) {

})
},

refreshOpenid() {
var self = this
var jscode = ''
wx.login({
success: function (res) {
// success
jscode = res.code


networkUtil._get(api.refreshOpenId + "?jscode=" + jscode + "&type=2", {}, function (res) {

console.log(res)
self.getPayMessage()
}, function (res) {

})
},
fail: function (res) {
// fail
},
complete: function (res) {
// complete
}
})
},

getPayMessage(){
networkUtil.showLoading()
var self = this
networkUtil._get(api.buy + '?goodsOrderId=' + self.data.OriginalorderId, { }, function (res) {

console.log(res)
wx.requestPayment({
timeStamp: res.data.payParams.timeStamp + "",
nonceStr: res.data.payParams.nonceStr,
package: res.data.payParams.package,
signType: res.data.payParams.signType,
paySign: res.data.payParams.paySign,
'success': function (res1) {
console.log(res1)
app.globalData.userInfo.status = 1
event.emit('userStatusChange', { });
wx.navigateBack({
})
},
'fail': function (res1) {
console.log('fali', res1)
wx.showToast({
title: '支付失败',
})
}
})
}, function (res) {

})
},
payClick:function(e){
this.refreshOpenid()
}
})