1.对接公众号 微信支付

yj-dev
杨杰 3 years ago
parent f7d9d64673
commit 86c053cce5
  1. 30
      node_modules/jweixin-module/README.md
  2. 1
      node_modules/jweixin-module/lib/index.js
  3. 54
      node_modules/jweixin-module/package.json
  4. 5
      package-lock.json
  5. 65
      pages/pay/payment/payment.vue
  6. 20
      pages/tabBar/user/user.vue

@ -0,0 +1,30 @@
# jweixin-module
微信JS-SDK
## 安装
### NPM
```shell
npm install jweixin-module --save
```
### UMD
```http
https://unpkg.com/jweixin-module/out/index.js
```
## 使用
```js
var jweixin = require('jweixin-module')
jweixin.ready(function(){
// TODO
});
```
## 完整API
>[微信JS-SDK说明文档](https://mp.weixin.qq.com/wiki?t=resource/res_main&id=mp1421141115)

File diff suppressed because one or more lines are too long

@ -0,0 +1,54 @@
{
"_from": "jweixin-module",
"_id": "jweixin-module@1.6.0",
"_inBundle": false,
"_integrity": "sha512-dGk9cf+ipipHmtzYmKZs5B2toX+p4hLyllGLF6xuC8t+B05oYxd8fYoaRz0T30U2n3RUv8a4iwvjhA+OcYz52w==",
"_location": "/jweixin-module",
"_phantomChildren": {},
"_requested": {
"type": "tag",
"registry": true,
"raw": "jweixin-module",
"name": "jweixin-module",
"escapedName": "jweixin-module",
"rawSpec": "",
"saveSpec": null,
"fetchSpec": "latest"
},
"_requiredBy": [
"#USER",
"/"
],
"_resolved": "https://registry.npmjs.org/jweixin-module/-/jweixin-module-1.6.0.tgz",
"_shasum": "4a7ea614083e3c9c3f49e2fdc2bb882cfa58dfcd",
"_spec": "jweixin-module",
"_where": "D:\\Documents\\high-mini",
"author": {
"name": "Shengqiang Guo"
},
"bugs": {
"url": "https://github.com/zhetengbiji/jweixin-module/issues"
},
"bundleDependencies": false,
"deprecated": false,
"description": "微信JS-SDK",
"devDependencies": {},
"homepage": "https://github.com/zhetengbiji/jweixin-module#readme",
"keywords": [
"wxjssdk",
"weixin",
"jweixin",
"wechat",
"jssdk",
"wx"
],
"license": "ISC",
"main": "lib/index.js",
"name": "jweixin-module",
"repository": {
"type": "git",
"url": "git+https://github.com/zhetengbiji/jweixin-module.git"
},
"scripts": {},
"version": "1.6.0"
}

5
package-lock.json generated

@ -2,6 +2,11 @@
"requires": true,
"lockfileVersion": 1,
"dependencies": {
"jweixin-module": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/jweixin-module/-/jweixin-module-1.6.0.tgz",
"integrity": "sha512-dGk9cf+ipipHmtzYmKZs5B2toX+p4hLyllGLF6xuC8t+B05oYxd8fYoaRz0T30U2n3RUv8a4iwvjhA+OcYz52w=="
},
"vue-jsonp": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/vue-jsonp/-/vue-jsonp-2.0.0.tgz",

@ -65,7 +65,8 @@
orderToPay,
orderToGoldPay
} from '../../../Utils/Api.js'
let app = getApp()
let app = getApp();
var jweixin = require('jweixin-module');
export default {
data() {
return {
@ -75,7 +76,7 @@
paytype: '', //
orderNo: '',
user: '',
couponId : ''
couponId: ''
};
},
onLoad(e) {
@ -120,7 +121,7 @@
}
orderToPay(params).then(res => {
if (res.return_code == '000000') {
alert('=============================')
// #ifdef MP
uni.requestPayment({
"appId": res.return_data.appId,
"nonceStr": res.return_data.nonceStr,
@ -139,9 +140,16 @@
},
fail: function(err) {
uni.hideLoading();
console.log('fail:' + JSON.stringify(err));
}
},
});
// #endif
//
// #ifdef H5
//
that.payRequest(res);
// #endif
} else {
uni.showToast({
title: res.return_msg,
@ -189,6 +197,53 @@
})
}
},
payRequest: function(self) {
jweixin.config({
debug: true, // ,apialertpclogpc
appId: self.return_data.appId, //
timestamp: self.return_data.timeStamp, //
nonceStr: self.return_data.nonceStr, //
signature: self.return_data.sign, // 1
jsApiList: ['chooseWXPay'] // 使JSJS2
});
jweixin.ready(function() {
jweixin.checkJsApi({
jsApiList: ['chooseWXPay'], // JSJS2,
success: function(res) {
},
fail: function(res) {
}
});
jweixin.chooseWXPay({
appId: self.return_data.appId,
timestamp: self.return_data.timeStamp, // jssdk使timestamp使timeStampS
nonceStr: self.return_data.nonceStr, // 32
package: self.return_data.package, // prepay_idprepay_id=***
signType: 'MD5', // 'SHA1'使'MD5'
paySign: self.return_data.sign, //
success: function(res) {
//
},
cancel: function(r) {
},
fail: function(res) {
}
});
});
jweixin.error(function(res) {
uni.showToast({
icon: 'none',
title: '支付失败了',
duration: 4000
});
// configerrorconfigdebugresSPA
/*alert("config信息验证失败");*/
});
},
}
}
</script>

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save