Bladeren bron

no message

DESKTOP-SVI9JE1\muzen 1 jaar geleden
bovenliggende
commit
efec65e261

+ 17 - 0
src/api/pay.js

@@ -0,0 +1,17 @@
+import request from "@/utils/request";
+
+// openId
+export function openId(data) {
+  return request({
+    url: `/wxPay/wapAuth?code=${data}`,
+    method: "post"
+  });
+}
+
+// 下单
+export function wechatPay(data) {
+  return request({
+    url: `/wxPay/webPay?openId=${data}`,
+    method: 'post'
+  })
+}

+ 7 - 0
src/pages.json

@@ -168,6 +168,13 @@
 			"style": {
 				"navigationStyle": "custom"
 			}
+		},
+		{
+			// 支付
+			"path": "pages/pay/index",
+			"style": {
+				"navigationStyle": "custom"
+			}
 		}
 	]
 }

+ 2 - 2
src/pages/activity/index.vue

@@ -45,7 +45,7 @@ export default {
         activityId: this.form.activityId
       }).then(res => {
         if (res.data.code === 0) {
-          this.pic = res.data.data.pic
+          this.pic = res.data.pic
         } else {
           uni.showToast({
             title: res.data.message,
@@ -61,7 +61,7 @@ export default {
       submit(this.form).then(res => {
         if (res.data.code === 0) {
           this.$refs.popup.open()
-          this.content = res.data.data
+          this.content = res.data
           this.isShow = true
         } else {
           uni.showToast({

+ 1 - 1
src/pages/agreement/index.vue

@@ -22,7 +22,7 @@ export default {
         type: type
       }).then(res => {
         if (res.data.code === 0) {
-          this.form = res.data.data
+          this.form = res.data
         }
       })
     },

+ 8 - 8
src/pages/article/index.vue

@@ -12,8 +12,8 @@
           <view flex center>
             <img class="avatar" :src="item.userAvatar" />
             <view style="opacity: 0.7; margin-left: 20rpx">
-              <view style="fontSize: 26rpx">{{ item.userName }}</view>
-              <view style="fontSize: 22rpx">{{ item.createTime }}</view>
+              <view style="font-size: 26rpx">{{ item.userName }}</view>
+              <view style="font-size: 22rpx">{{ item.createTime }}</view>
             </view>
           </view>
           <view flex center style="opacity: 0.7">
@@ -22,7 +22,7 @@
           </view>
         </view>
         <view class="item-content">
-          <view style="fontSize:28rpx">
+          <view style="font-size:28rpx">
             {{ item.content }}
           </view>
           <view class="sub-content" v-if="item.replyList.length > 0">
@@ -79,9 +79,9 @@ export default {
         articleId: e.articleId
       }).then(res => {
         if (res.data.code === 0) {
-          this.url = res.data.data.pic
-          this.title = res.data.data.title
-          this.content = res.data.data.content
+          this.url = res.data.pic
+          this.title = res.data.title
+          this.content = res.data.content
         }
       })
       this.getList()
@@ -106,10 +106,10 @@ export default {
     getList() {
       list(this.form).then(res => {
         if (res.data.code === 0) {
-          res.data.data.records.map(i => {
+          res.data.records.map(i => {
             this.tableData.push(i)
           })
-          this.hasMore = res.data.data.hasMore
+          this.hasMore = res.data.hasMore
         }
       })
     }

+ 2 - 2
src/pages/channel/index.vue

@@ -53,8 +53,8 @@ export default {
     getList() {
       list({ ...this.dev, ...this.listForm }).then(res => {
         if (res.data.code === 0) {
-          res.data.data.records.map(i => this.list.push(i))
-          this.hasMore = res.data.data.hasMore
+          res.data.records.map(i => this.list.push(i))
+          this.hasMore = res.data.hasMore
         }
       })
     },

+ 4 - 4
src/pages/content/index.vue

@@ -61,20 +61,20 @@ export default {
         articleId: articleId
       }).then(res => {
         if (res.data.code === 0) {
-          if (res.data.data.templateType == 1) {
+          if (res.data.templateType == 1) {
             // 按sort从小到大排序
-            res.data.data.contentShareLayoutList.sort(function (x, y) {
+            res.data.contentShareLayoutList.sort(function (x, y) {
               return x.sort > y.sort ? 1 : -1
             })
             // 给单音频添加播放状态
-            res.data.data.contentShareLayoutList.map(i => {
+            res.data.contentShareLayoutList.map(i => {
               if ([2, 6, 11].includes(i.contentType)) {
                 i.playStatus = 2
               }
             })
           }
 
-          this.form = res.data.data
+          this.form = res.data
 
           // 检测当前是否有正在播放的音频
           if (this.inside) {

+ 1 - 1
src/pages/devices/detail.vue

@@ -19,7 +19,7 @@ export default {
     getDetail(e) {
       detail(e).then(res => {
         if (res.data.code === 0) {
-          this.content = res.data.data.content
+          this.content = res.data.content
         } else {
           uni.showToast({
             title: res.data.message,

+ 1 - 1
src/pages/guide/index.vue

@@ -26,7 +26,7 @@ export default {
       }
       detail(data).then(res => {
         if (res.data.code === 0) {
-          this.content = res.data.data.guidePageContent
+          this.content = res.data.guidePageContent
         }
       })
     }

+ 2 - 2
src/pages/help/detail.vue

@@ -48,10 +48,10 @@ export default {
     getDetail() {
       detail(this.form).then(res => {
         if (res.data.code === 0) {
-          res.data.data.records.map(i => {
+          res.data.records.map(i => {
             this.tableData.push(i)
           })
-          this.hasMore = res.data.data.hasMore
+          this.hasMore = res.data.hasMore
         }
       })
     }

+ 1 - 1
src/pages/help/index.vue

@@ -69,7 +69,7 @@ export default {
     getList() {
       list().then(res => {
         if (res.data.code === 0) {
-          this.typeOptions = res.data.data
+          this.typeOptions = res.data
         }
       })
     },

+ 1 - 1
src/pages/imusic/index.vue

@@ -36,7 +36,7 @@ export default {
     getDetail(e) {
       detail({ id: e }).then(res => {
         if (res.data.code === 0) {
-          this.form = res.data.data
+          this.form = res.data
         }
       })
     },

+ 5 - 5
src/pages/lottery/index.vue

@@ -27,14 +27,14 @@
     <!-- 弹窗 -->
     <uni-popup ref="popup" type="center" :is-mask-click="false">
       <view v-if="this.hasLotteryCount <= 0" class="popup" style="justify-content: space-around">
-        <view style="fontSize: 36rpx">
+        <view style="font-size: 36rpx">
           <view>很遗憾!</view>
           <view>今日抽奖次数已用光</view>
         </view>
         <img src="../../static/lottery/noChance.png" />
       </view>
       <view v-else class="popup">
-        <view style="fontSize: 36rpx">{{ form.resultGoodName }}</view>
+        <view style="font-size: 36rpx">{{ form.resultGoodName }}</view>
         <img :src="form.resultGoodPic" />
         <button v-if="form.resultGoodType === 4" @click="getSubmit">领取</button>
         <button v-if="form.resultGoodType === 5" @click="getAgain">再抽一次</button>
@@ -94,7 +94,7 @@ export default {
       this.prizes = []
       page(getApp().globalData.userInfo).then(res => {
         if (res.data.code === 0) {
-          const j = res.data.data
+          const j = res.data
           // 可用积分
           this.maySignPoint = j.maySignPoint
           // 每次消耗积分
@@ -138,8 +138,8 @@ export default {
             result(getApp().globalData.userInfo).then(res => {
               if (res.data.code === 0) {
                 setTimeout(() => {
-                  this.$refs.lucky.stop(res.data.data.resultGoodSort - 1)
-                  this.form = res.data.data
+                  this.$refs.lucky.stop(res.data.resultGoodSort - 1)
+                  this.form = res.data
                 }, 3000)
               } else {
                 this.$refs.lucky.stop()

+ 5 - 5
src/pages/map/index.vue

@@ -208,7 +208,7 @@ export default {
               if (res.data.code === 0) {
                 let value = []
                 // 市
-                that.locationList[0] = res.data.data
+                that.locationList[0] = res.data
                 value[0] = that.locationList[0].findIndex(i => e.province.includes(i.name))
                 that.form.province = that.locationList[0][value[0]].id
                 that.province = that.locationList[0][value[0]].name
@@ -324,12 +324,12 @@ export default {
       this.map.clearMap()
       list(this.form).then(res => {
         if (res.data.code === 0) {
-          if (res.data.data.records.length > 0) {
-            res.data.data.records.map(i => {
+          if (res.data.records.length > 0) {
+            res.data.records.map(i => {
               this.list.push(i)
               this.getMarker(i.longitude, i.latitude)
             })
-            this.hasMore = res.data.data.hasMore
+            this.hasMore = res.data.hasMore
             this.map.setCenter([this.list[0].longitude, this.list[0].latitude])
           } else {
             this.getStoreList()
@@ -350,7 +350,7 @@ export default {
     getStoreList() {
       storeList().then(res => {
         if (res.data.code === 0) {
-          this.storeList = res.data.data
+          this.storeList = res.data
         }
       })
     },

+ 63 - 0
src/pages/pay/index.vue

@@ -0,0 +1,63 @@
+<template>
+  <div class='app-container'>
+    <button @click="getWechatPay">下单</button>
+  </div>
+</template>
+
+<script>
+import { openId, wechatPay } from "@/api/pay"
+export default {
+  data() {
+    return {
+      openId: '',
+      // 下单表单
+      form: {}
+    }
+  },
+  onLoad(e) {
+    this.getOpenId(e)
+  },
+  methods: {
+    // 获取openId
+    getOpenId(e) {
+      openId(e.code).then(res => {
+        console.log(res.data);
+        if(res.data.code === 0) {
+          this.openId = res.data.openid
+        }
+      })
+    },
+
+    // 下单
+    getWechatPay() {
+      wechatPay(this.openId).then(res => {
+        console.log(JSON.parse(res.data));
+        if (res.data.code === 0) {
+          this.form = JSON.parse(res.data)
+          if (typeof WeixinJSBridge == 'undefined') {
+            if (document.addEventListener) {
+              document.addEventListener('WeixinJSBridge', this.onBridgeReady(), false)
+            } else if (document.attachEvent) {
+              document.attachEvent('WeixinJSBridge', this.onBridgeReady())
+              document.attachEvent('onWeixinJSBridgeReady', this.onBridgeReady())
+            }
+          } else {
+            this.onBridgeReady()
+          }
+        }
+      })
+    },
+
+    // 调起支付
+    onBridgeReady() {
+      WeixinJSBridge.invoke('getBrandWCPayRequest', this.form, function (res) {
+        console.log(res);
+        if (res.err_msg == "get_brand_wcpay_request:ok") {
+          // 使用以上方式判断前端返回,微信团队郑重提示:
+          //res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
+        }
+      })
+    }
+  }
+}
+</script>

+ 1 - 1
src/pages/share/channels.vue

@@ -36,7 +36,7 @@ export default {
         userId: e.userId
       }).then(res => {
         if (res.data.code === 0) {
-          this.list = res.data.data
+          this.list = res.data
         }
       })
     }

+ 3 - 3
src/pages/share/controls.vue

@@ -44,7 +44,7 @@ export default {
           audioId: e.audioId
         }).then(res => {
           if (res.data.code === 0) {
-            this.form = res.data.data
+            this.form = res.data
           }
         })
       } else {
@@ -52,8 +52,8 @@ export default {
           audioId: e.audioId
         }).then(res => {
           if (res.data.code === 0) {
-            this.form = res.data.data
-            this.form.icon = res.data.data.audioPic
+            this.form = res.data
+            this.form.icon = res.data.audioPic
           }
         })
       }

+ 6 - 6
src/pages/share/detail.vue

@@ -28,12 +28,12 @@
       activeColor="#fff" />
     <view v-show="current === 0" class="list_content">
       <uni-row class="item" v-for="(item, index) in list" :key="item.id" @click.native="open">
-        <uni-col :span="2" style="color:#FFFFFF66; fontSize: 28rpx; fontWeight:bold">
+        <uni-col :span="2" style="color:#FFFFFF66; font-size: 28rpx; font-weight:bold">
           {{ index + 1}}
         </uni-col>
         <uni-col :span="20">
-          <view style="fontSize: 32rpx; margin-bottom: 10rpx;">{{ item.name }}</view>
-          <view style="display:flex; fontSize:22rpx; color:#FFFFFF66;">
+          <view style="font-size: 32rpx; margin-bottom: 10rpx;">{{ item.name }}</view>
+          <view style="display:flex; font-size:22rpx; color:#FFFFFF66;">
             <text class="time">{{ item.durationText }}</text>
             <text class="play">{{ item.playcount }}</text>
             <text class="date">{{ item.updateTimeText }}</text>
@@ -85,8 +85,8 @@ export default {
     getList() {
       podCastProgramList(this.form).then(res => {
         if (res.data.code === 0) {
-          this.list = res.data.data.records
-          this.total = res.data.data.total
+          this.list = res.data.records
+          this.total = res.data.total
         }
       })
     },
@@ -96,7 +96,7 @@ export default {
         audioId: this.form.audioId
       }).then(res => {
         if (res.data.code === 0) {
-          this.data = res.data.data
+          this.data = res.data
         }
       })
     },

+ 3 - 3
src/pages/share/list.vue

@@ -62,7 +62,7 @@ export default {
         userId: e.userId
       }).then(res => {
         if (res.data.code === 0) {
-          this.data = res.data.data
+          this.data = res.data
         }
       })
       this.getList()
@@ -79,8 +79,8 @@ export default {
     getList() {
       channelAudioPage(this.form).then(res => {
         if (res.data.code === 0) {
-          this.list = res.data.data.records
-          this.total = res.data.data.total
+          this.list = res.data.records
+          this.total = res.data.total
         }
       })
     },

+ 1 - 1
src/utils/request.js

@@ -15,7 +15,7 @@ function request(e) {
       method: e.method,
       data: e.data,
       success: (res) => {
-        resolve(res)
+        resolve(res.data)
         uni.hideLoading()
       },
       fail: (err) => {