|
@@ -65,53 +65,58 @@ Page({
|
|
|
*/
|
|
|
onShareAppMessage() {
|
|
|
|
|
|
+ },
|
|
|
+ pay(){
|
|
|
+ api.request_wechatPay(1)
|
|
|
+ .then(res => {
|
|
|
+ wx.requestPayment({
|
|
|
+ timeStamp: res.data.data.unifiedOrderResult.timeStamp,
|
|
|
+ nonceStr: res.data.data.unifiedOrderResult.nonceStr,
|
|
|
+ package: res.data.data.unifiedOrderResult.package,
|
|
|
+ signType: res.data.data.unifiedOrderResult.signType,
|
|
|
+ paySign: res.data.data.unifiedOrderResult.paySign,
|
|
|
+ success: res => {
|
|
|
+ wx.hideLoading()
|
|
|
+ wx.showToast({
|
|
|
+ title: '支付成功!',
|
|
|
+ })
|
|
|
+ setTimeout(function () {
|
|
|
+ wx.switchTab({
|
|
|
+ url: '../index/index',
|
|
|
+ })
|
|
|
+ }, 2000)
|
|
|
+
|
|
|
+ },
|
|
|
+ fail: res => {
|
|
|
+ wx.hideLoading()
|
|
|
+ wx.showModal({
|
|
|
+ title: '支付失败',
|
|
|
+ content: res.errMsg + '请稍后再试',
|
|
|
+ showCancel: false,
|
|
|
+ success(res) {
|
|
|
+ if (res.confirm) {
|
|
|
+ wx.switchTab({
|
|
|
+ url: '../home/home',
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ })
|
|
|
+ });
|
|
|
},
|
|
|
handleAuthLogin() {
|
|
|
console.log('一键授权登录按钮被点击');
|
|
|
- api.request_wechatPay(1)
|
|
|
- .then(res => {
|
|
|
- wx.requestPayment({
|
|
|
- timeStamp: res.data.data.unifiedOrderResult.timeStamp,
|
|
|
- nonceStr: res.data.data.unifiedOrderResult.nonceStr,
|
|
|
- package: res.data.data.unifiedOrderResult.package,
|
|
|
- signType: res.data.data.unifiedOrderResult.signType,
|
|
|
- paySign: res.data.data.unifiedOrderResult.paySign,
|
|
|
- success: res => {
|
|
|
- wx.hideLoading()
|
|
|
- wx.showToast({
|
|
|
- title: '支付成功!',
|
|
|
- })
|
|
|
- setTimeout(function () {
|
|
|
- wx.switchTab({
|
|
|
- url: '../index/index',
|
|
|
- })
|
|
|
- }, 2000)
|
|
|
-
|
|
|
- },
|
|
|
- fail: res => {
|
|
|
- wx.hideLoading()
|
|
|
- wx.showModal({
|
|
|
- title: '支付失败',
|
|
|
- content: res.errMsg + '请稍后再试',
|
|
|
- showCancel: false,
|
|
|
- success(res) {
|
|
|
- if (res.confirm) {
|
|
|
- wx.switchTab({
|
|
|
- url: '../home/home',
|
|
|
- })
|
|
|
- }
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
- });
|
|
|
// 调用微信登录接口
|
|
|
wx.login({
|
|
|
success(res) {
|
|
|
if (res.code) {
|
|
|
console.log('登录成功,code:', res.code);
|
|
|
- // 将 code 发送到服务器,获取用户信息
|
|
|
- // 例如:wx.request({ url: 'https://example.com/login', data: { code: res.code } })
|
|
|
+ api.request_Wechatlogin(res.code)
|
|
|
+ .then(res => {
|
|
|
+ debugger
|
|
|
+ wx.setStorageSync('WachatID', res.data.data)
|
|
|
+ });
|
|
|
} else {
|
|
|
console.log('登录失败:', res.errMsg);
|
|
|
}
|