Commit 588189ba by 张立顺

v4.8.0 生产环境代码

1 parent 41b3dcfa
## 预发布环境appId
wx902f0b9c4b2c669d
appsecret(小程序秘钥)55c50d6b63cec072a74288a628395ca0
## 其他环境的appId
wx06d1198e751435d1
sass+ v4.8.0 微信扫码支付功能开发
\ No newline at end of file \ No newline at end of file
{ {
"pages": [ "pages": ["pages/tab/index/index", "pages/tab/personal/personal", "pages/auth/userInfo/userInfo", "pages/auth/phone/phone", "pages/route/to", "pages/webpage/webpage", "pages/upgrade/upgrade", "pages/auth/login/login", "pages/auth/index/index", "pages/tab/logout/logout"],
"pages/tab/index/index", "requiredPrivateInfos": ["getLocation", "chooseAddress", "chooseLocation"],
"pages/tab/personal/personal",
"pages/auth/userInfo/userInfo",
"pages/auth/phone/phone",
"pages/route/to",
"pages/webpage/webpage",
"pages/upgrade/upgrade",
"pages/auth/login/login",
"pages/auth/index/index",
"pages/tab/logout/logout"
],
"window": { "window": {
"backgroundTextStyle": "light", "backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#fff", "navigationBarBackgroundColor": "#fff",
...@@ -149,30 +139,21 @@ ...@@ -149,30 +139,21 @@
{ {
"name": "payment", "name": "payment",
"root": "packagesPayment", "root": "packagesPayment",
"pages": [ "pages": ["pages/payment/index", "pages/QRPayment/QRPayment"]
"pages/payment/index",
"pages/QRPayment/QRPayment"
]
} }
], ],
"preloadRule": { "preloadRule": {
"pages/tab/index/index": { "pages/tab/index/index": {
"network": "all", "network": "all",
"packages": [ "packages": ["homeindex"]
"homeindex"
]
}, },
"pages/tab/personal/personal": { "pages/tab/personal/personal": {
"network": "all", "network": "all",
"packages": [ "packages": ["personal"]
"personal"
]
}, },
"packagePersonal/pages/smartplus/smartplus": { "packagePersonal/pages/smartplus/smartplus": {
"network": "all", "network": "all",
"packages": [ "packages": ["smartplus"]
"smartplus"
]
} }
} }
} }
// packagesPayment/pages/QRPayment/QRPayment.js // packagesPayment/pages/QRPayment/QRPayment.js
// import api from '../../restapiQrPay'
import api from '../../restapi' import api from '../../restapi'
const util = require('../../../utils/util.js') const util = require('../../../utils/util.js')
const app = getApp() const app = getApp()
...@@ -17,14 +18,15 @@ Page({ ...@@ -17,14 +18,15 @@ Page({
unpaid: true, unpaid: true,
showOrderInfo: false, showOrderInfo: false,
transactionReferenceNumber: '', transactionReferenceNumber: '',
dataTime: '',
orderInfoList: [ orderInfoList: [
// { name: 'merchantName', label: '商户名称', info: '' }, // { name: 'merchantName', label: '商户名称', info: '' },
// { name: 'outTradeNo', label: '交易参考号', info: '' }, // { name: 'outTradeNo', label: '交易参考号', info: '' },
{ name: 'tradeNo', label: '流水号', info: '' }, { name: 'tradeNo', label: '流水号', info: '' },
{ name: 'payTime', label: '支付时间', info: '' } { name: 'payTime', label: '支付时间', info: '' }
], ],
openId: 'oQ6Sh5cGirPd55Oc1J1oJSRpboFM', // openId: 'oQ6Sh5cGirPd55Oc1J1oJSRpboFM',
// openId: '', openId: '',
outTradeNo: '' outTradeNo: ''
}, },
...@@ -34,6 +36,7 @@ Page({ ...@@ -34,6 +36,7 @@ Page({
onLoad: function (options) { onLoad: function (options) {
// console.log('app', app.globalData.login()) // console.log('app', app.globalData.login())
console.log(options) console.log(options)
this.gteOpenId() this.gteOpenId()
wx.hideHomeButton({ wx.hideHomeButton({
success: function () { success: function () {
...@@ -81,6 +84,7 @@ Page({ ...@@ -81,6 +84,7 @@ Page({
var self = this var self = this
// self.globalData.code = res.code // self.globalData.code = res.code
console.log('login', res) console.log('login', res)
console.log(api)
// restapi.jsTestLogin(res.code, self.globalData.appId, function (response) { // restapi.jsTestLogin(res.code, self.globalData.appId, function (response) {
api.authOpenId({ code: res.code, appId: app.globalData.appId }, function (response) { api.authOpenId({ code: res.code, appId: app.globalData.appId }, function (response) {
console.log('response', response) console.log('response', response)
...@@ -188,7 +192,9 @@ Page({ ...@@ -188,7 +192,9 @@ Page({
// 调用支付接口生成对应的微信支付参数 // 调用支付接口生成对应的微信支付参数
// console.log(params) // console.log(params)
// return // return
api.createWxPayOrderH5(params, res => { api.createWxPayOrderH5(
params,
res => {
util.hideLoading() util.hideLoading()
console.log(res) console.log(res)
let { returnCode, data } = res let { returnCode, data } = res
...@@ -202,7 +208,16 @@ Page({ ...@@ -202,7 +208,16 @@ Page({
_this.wxPayment(jsapiPayInfo) _this.wxPayment(jsapiPayInfo)
} }
// console.log(JSON.parse(res.data)) // console.log(JSON.parse(res.data))
},
fail => {
console.log(fail)
util.hideLoading()
wx.showToast({
title: '支付请求失败',
icon: 'error'
}) })
}
)
// api.queryPayOrderStatus(params, res => { // api.queryPayOrderStatus(params, res => {
// // util.hideLoading() // // util.hideLoading()
// console.log(res) // console.log(res)
...@@ -230,11 +245,18 @@ Page({ ...@@ -230,11 +245,18 @@ Page({
success: function (res) { success: function (res) {
console.log(res) console.log(res)
// 查询订单信息 // 查询订单信息
util.showLoading('加载中...') // util.showLoading('加载中...')
wx.setNavigationBarTitle({ wx.setNavigationBarTitle({
title: '支付完成' title: '支付完成'
}) })
_this.successInfo() _this.setData({
unpaid: false,
dataTime: new Date().format('yyyy/MM/dd hh:mm')
// showOrderInfo: data ? true : false,
// orderInfoList
})
// 银盛接口取消调用(太慢没意义)
// _this.successInfo()
}, },
fail: function (error) { fail: function (error) {
wx.showToast({ wx.showToast({
......
...@@ -71,16 +71,20 @@ ...@@ -71,16 +71,20 @@
<view class="label">商户名称</view> <view class="label">商户名称</view>
<view class="info">{{merchantName}}</view> <view class="info">{{merchantName}}</view>
</view> </view>
<!-- <view class="orderInfo"> <view class="orderInfo">
<view class="label">交易参考号</view> <view class="label">支付订单号</view>
<view class="info">{{outTradeNo}}</view> <view class="info">{{outTradeNo}}</view>
</view> --> </view>
<block wx:for="{{orderInfoList}}" wx:for-item="item" wx:key="index"> <view class="orderInfo">
<view class="label">支付时间</view>
<view class="info">{{dataTime}}</view>
</view>
<!-- <block wx:for="{{orderInfoList}}" wx:for-item="item" wx:key="index">
<view class="orderInfo" wx:if="{{item.info}}"> <view class="orderInfo" wx:if="{{item.info}}">
<view class="label">{{item.label}}</view> <view class="label">{{item.label}}</view>
<view class="info">{{item.info}}</view> <view class="info">{{item.info}}</view>
</view> </view>
</block> </block> -->
<image class="logoIcon" src="../../../images/djLogin.png" /> <image class="logoIcon" src="../../../images/djLogin.png" />
</view> </view>
</view> </view>
......
// const restapi = require('../utils/util.js');
const restapi = require('../utils/restapi.js') const restapi = require('../utils/restapi.js')
module.exports = { module.exports = {
/** 获取订单数据*/ /** 获取订单数据*/
GETORDERINFO: function (oParams, success, fail) { GETORDERINFO: function (oParams, success, fail) {
...@@ -57,7 +57,6 @@ module.exports = { ...@@ -57,7 +57,6 @@ module.exports = {
'/web-dj-weapp/jscode/getOpenId', '/web-dj-weapp/jscode/getOpenId',
// JSON.stringify(code), // JSON.stringify(code),
params, params,
{ {
'content-type': 'application/x-www-form-urlencoded' 'content-type': 'application/x-www-form-urlencoded'
}, },
......
// const restapi = require('../utils/util.js')
const domain = 'https://dj.test.glsx.com.cn'
// import restapi from '../utils/restapi.js'
// console.log(restapi)
// const restapi = require('../utils/restapi.js')
const restapi = {}
restapi.req = request
console.log(restapi.req)
/**
* 通用请求
* url: 请求路径
* data: 数据参数
* header: 请求头
* method: 请求类型,默认GET,需大写
* dataType: 返回数据格式,默认json
* responseType: 响应数据类型,默认text
* success: 响应成功回调函数
*/
function request(url, data, header, method, dataType, responseType, success, fail) {
//埋点
var requestStartTime = Date.now()
wx.showNavigationBarLoading()
// 请求超时时间默认60秒
var timeout = 60000
if (header && header['request-timeout']) {
timeout = header['request-timeout']
delete header['request-timeout']
}
// 设置请求头,携带Cookie信息
setHeader(header)
var that = this
wx.request({
url: 'https://dj.test.glsx.com.cn' + url,
data: data,
header: header,
timeout: timeout,
method: method,
dataType: dataType,
responseType: responseType,
success: function (response) {
// 未登录
setHeader(response.header)
if (response.statusCode == 401) {
// 跳转到正在登录页面
wx.navigateTo({
url: '/pages/auth/login/login'
})
} else if (response.statusCode == 200) {
success(response.data)
} else {
if (fail && 'function' === typeof fail) {
fail()
}
}
},
fail: function (error) {
console.log('error:' + JSON.stringify(error))
if (fail && 'function' === typeof fail) {
fail()
}
},
complete: function (data) {
wx.hideNavigationBarLoading()
}
})
}
/**
* 设置请求头Cookie信息
* header 源请求头信息
* return 包含Cookie信息header
*/
function setHeader(header) {
var app = getApp()
if (app && app.globalData.extConfig.merchantId) {
header['MerchantId'] = app.globalData.extConfig.merchantId
}
var sessionKey = 'DJ_S_'
// 本地获取存储的sessionId
var sessionId = wx.getStorageSync(sessionKey)
if (sessionId) {
// 优先从本地获取sessionId
header['Cookie'] = [sessionKey, '=', sessionId].join('')
return header
}
// 本地没有,则从服务器获取
var cookies = header['Set-Cookie']
if (cookies) {
var re = new RegExp('' + sessionKey + '=([^;]*)', 'ig')
sessionId = cookies.match(re) ? cookies.match(re)[0].substr(sessionKey.length + 1) : null
if (sessionId) {
// 从cookie中获取sessionId存储到本地
wx.setStorageSync(sessionKey, sessionId)
}
}
if (sessionId) {
header['Cookie'] = [sessionKey, '=', sessionId].join('')
}
return header
}
module.exports = {
/** 获取订单数据*/
GETORDERINFO: function (oParams, success, fail) {
restapi.req('/web-dj-weapp/smartcarlife/goodsOrder/createWxPayOrder', oParams, {}, 'GET', 'json', 'text', success, fail)
},
/**
* 根据场景id获取场景值
*/
qrCodeScene: function (qrcodeScene, success, fail) {
restapi.req('/web-dj-weapp/home/qrCodeScene/getSceneById', qrcodeScene, {}, 'GET', 'json', 'text', success, fail)
},
/** 查询支付结果 */
queryPayOrderStatus: function (params, success, fail) {
restapi.req(
'/web-dj-weapp/smartcarlife/goodsOrder/queryPayOrderStatus',
params,
// {
// 'content-type': 'application/x-www-form-urlencoded'
// },
{
'content-type': 'application/json'
},
'POST',
'json',
'text',
success,
fail
)
},
/** 发起微信支付 */
createWxPayOrderH5: function (params, success, fail) {
restapi.req(
'/web-dj-weapp/smartcarlife/goodsOrder/createWxPayOrderH5',
params,
// {
// 'content-type': 'application/x-www-form-urlencoded'
// },
{
'content-type': 'application/json'
},
'POST',
'json',
'text',
success,
fail
)
},
/**
* 授权登录
* wechatAuthSetting:微信授权信息
*/
authOpenId: function (params, success, fail) {
restapi.req(
'/web-dj-weapp/jscode/getOpenId',
// JSON.stringify(code),
params,
{
'content-type': 'application/x-www-form-urlencoded'
},
'POST',
'json',
'text',
success,
fail
)
}
}
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"ignore": [] "ignore": []
}, },
"setting": { "setting": {
"urlCheck": false, "urlCheck": true,
"es6": false, "es6": false,
"enhance": true, "enhance": true,
"postcss": true, "postcss": true,
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
"disablePlugins": [], "disablePlugins": [],
"outputPath": "" "outputPath": ""
}, },
"enableEngineNative": false,
"useIsolateContext": true, "useIsolateContext": true,
"userConfirmedBundleSwitch": false, "userConfirmedBundleSwitch": false,
"packNpmManually": false, "packNpmManually": false,
...@@ -39,10 +38,11 @@ ...@@ -39,10 +38,11 @@
"disableUseStrict": false, "disableUseStrict": false,
"minifyWXML": true, "minifyWXML": true,
"showES6CompileOption": false, "showES6CompileOption": false,
"useCompilerPlugins": false "useCompilerPlugins": false,
"ignoreUploadUnusedFiles": true
}, },
"compileType": "miniprogram", "compileType": "miniprogram",
"libVersion": "2.21.0", "libVersion": "2.8.3",
"appid": "wx06d1198e751435d1", "appid": "wx06d1198e751435d1",
"projectname": "dj-scrm-weapp-smartshop", "projectname": "dj-scrm-weapp-smartshop",
"debugOptions": { "debugOptions": {
......
...@@ -279,6 +279,13 @@ ...@@ -279,6 +279,13 @@
"query": "scene=sceneId%3D4", "query": "scene=sceneId%3D4",
"scene": null, "scene": null,
"launchMode": "default" "launchMode": "default"
},
{
"name": "",
"pathName": "packagePersonal/pages/address/address",
"query": "",
"launchMode": "default",
"scene": null
} }
] ]
} }
......
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
// const domain = 'http://192.168.3.181:9182' // const domain = 'http://192.168.3.181:9182'
// const domain = 'https://dj.dev.glsx.com.cn' // const domain = 'https://dj.dev.glsx.com.cn'
// env:uat // env:uat
const domain = 'https://dj.test.glsx.com.cn' // const domain = 'https://dj.test.glsx.com.cn'
// env:prod // env:prod
// const domain = 'https://dj.glsx.com.cn' const domain = 'https://dj.glsx.com.cn'
const app = getApp() const app = getApp()
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!