애플릿 기능 (6) 결제

6400 단어 소절차
## 
//appid+secret
  wx.login({
          success: function(res) {
            var code = res.code;
            wx.request({
              url:
                "https://api.weixin.qq.com/sns/jscode2session?appid=appid&secret=secret&js_code=" +code +"&grant_type=authorization_code",
              method: "POST",
              success(res) {
                console.log(res);
                payMP({
                  order_id: that.options.id,// id
                  openid: res.data.openid
                }).then(res => {
                  console.log(res, " ");
                  wx.requestPayment({
                    timeStamp: res.data.timeStamp,
                    nonceStr: res.data.nonceStr,
                    package: res.data.package,
                    signType: res.data.signType,
                    paySign: res.data.paySign,
                    success(res) {
                      if (res.errMsg == "requestPayment:ok") {
                        paySuccess({
                          token: wx.getStorageSync("token").token,
                          main_id: that.options.id
                        }).then(res => {
                          console.log(res, "chenggong");
                          if (res.data == 1) {
                            Toast(" ");
                            setTimeout(() => {
                              wx.switchTab({
                                url: "/pages/order/index/main"
                              });
                            }, 2000);
                          } else {
                            Toast(" , ");
                          }
                        });
                      }
                    },
                    fail(res) {
                      Toast(" , ");
                    }
                  });
                });
              }
            });
          }
        });

좋은 웹페이지 즐겨찾기