shenxin 5 vuotta sitten
vanhempi
commit
56e67b8934

+ 7 - 2
src/api/request.js

@@ -1,7 +1,7 @@
 /*
  * @Author: your name
  * @Date: 2021-01-25 11:32:04
- * @LastEditTime: 2021-01-25 13:33:39
+ * @LastEditTime: 2021-01-26 13:32:34
  * @LastEditors: Please set LastEditors
  * @Description: In User Settings Edit
  * @FilePath: \rebatedine-mini\src\api\request.js
@@ -41,11 +41,16 @@ export default {
 
     return new Promise(resolve => {
       options.complete = ({ statusCode, data }) => {
-        if (statusCode !== 200) {
+        console.log(data)
+        if (
+          statusCode !== 200 ||
+          !Object.prototype.hasOwnProperty.call(data, 'code')
+        ) {
           uni.showToast({
             title: '系统异常',
             icon: 'none'
           })
+          resolve(false)
           return
         }
         data.code = data.code * 1

+ 71 - 63
src/pages/my.vue

@@ -1,31 +1,39 @@
 <template>
   <view class="pensonal">
     <network-error />
-    <view class="login u-flex" @click="login">
+    <view class="login u-flex"
+          @click="login">
       <block v-if="!userInfo.nick_name">
-      <image class="avatar" src="~@/static/icon/avatar.png"></image>
+        <image class="avatar"
+               src="~@/static/icon/avatar.png"></image>
         <text class="name u-content-color line-50 ml-16 u-flex-1 bold">点击登录</text>
       </block>
       <block v-else>
-      <image class="avatar" :src="userInfo.head_url"></image>
+        <image class="avatar"
+               :src="userInfo.head_url"></image>
         <view class="name line-50 ml-16 u-flex-1 u-line-1 bold">{{userInfo.nick_name}}</view>
       </block>
-      <block v-if="userInfo.id">
-        <view class="info u-font-22" @click.stop="toUserDetail">个人信息<u-icon name="arrow-right"></u-icon></view>
+      <block v-if="userInfo.token">
+        <view class="info u-font-22"
+              @click.stop="toUserDetail">个人信息<u-icon name="arrow-right"></u-icon>
+        </view>
       </block>
     </view>
     <view class="item-list">
-      <view class="item u-flex u-border-bottom" @click="toDetail(1)">
+      <view class="item u-flex u-border-bottom"
+            @click="toDetail(1)">
         <view class="icon-wh icon-problem"></view>
         <view class="u-font-28 ml-28 u-flex-1 title">常见问题</view>
         <view class="jiantou-wh icon-jiantou "></view>
       </view>
-      <view class="item u-flex u-border-bottom" @click="toDetail(2)">
+      <view class="item u-flex u-border-bottom"
+            @click="toDetail(2)">
         <view class="icon-wh icon-aboutour"></view>
         <view class="u-font-28 ml-28 u-flex-1 title">关于我们</view>
         <view class="jiantou-wh icon-jiantou "></view>
       </view>
-      <view class="item u-flex" @click="toDetail(3)">
+      <view class="item u-flex"
+            @click="toDetail(3)">
         <view class="icon-wh icon-order"></view>
         <view class="u-font-28 ml-28 u-flex-1 title">订单</view>
         <view class="jiantou-wh icon-jiantou"></view>
@@ -61,7 +69,7 @@ export default {
     },
     // 登录
     login () {
-      if (this.userInfo.id) { return }
+      if (this.userInfo.token) { return }
       uni.navigateTo({
         url: '/pagesSub/other/login'
       })
@@ -77,61 +85,61 @@ export default {
 </script>
 
 <style lang="scss" scoped>
-  .pensonal {
-    width: 750px;
-    background: #FFF;
-  }
-  .login {
-    width: 100%;
-    height: 156px;
-    align-items: center;
-    padding: 8px 0 40px 40px;
-  }
-  .info {
-    width: 124px;
-    height: 48px;
-    line-height: 48px;
-    background: $bg-personl-info-color;
-    color: #FFFFFF;
-    text-align: right;
-    border-radius: 100px 0px 0px 100px;
-  }
-  .avatar {
-    width: 108px;
-    height: 108px;
-    border-radius: 54px;
-  }
-  .name {
-    width: 414px;
-    height: 50px;
-    font-size: 36px;
-    margin-left: 16px;
-  }
-  .item-list {
+.pensonal {
+  width: 750px;
+  background: #fff;
+}
+.login {
+  width: 100%;
+  height: 156px;
+  align-items: center;
+  padding: 8px 0 40px 40px;
+}
+.info {
+  width: 124px;
+  height: 48px;
+  line-height: 48px;
+  background: $bg-personl-info-color;
+  color: #ffffff;
+  text-align: right;
+  border-radius: 100px 0px 0px 100px;
+}
+.avatar {
+  width: 108px;
+  height: 108px;
+  border-radius: 54px;
+}
+.name {
+  width: 414px;
+  height: 50px;
+  font-size: 36px;
+  margin-left: 16px;
+}
+.item-list {
+  width: 100%;
+  background: #fff;
+  box-sizing: border-box;
+  padding: 0 32px 0 40px;
+  .item {
     width: 100%;
-    background: #FFF;
-    box-sizing: border-box;
-    padding: 0 32px 0 40px;
-    .item {
-      width: 100%;
-      height: 96px;
-      .title {
-        color: $u-main-color;
-      }
+    height: 96px;
+    .title {
+      color: $u-main-color;
     }
   }
-  // .border-bottom {
-  //   border-bottom: 1px solid $u-border-color;
-  // }
-  .icon-wh {
-    width: 36px;
-    height: 36px;
-  }
-  .jiantou-wh {
-    width: 14px;
-    height: 24px;
-  }
-  .ml-28 {
-    margin-left: 28px;
-  }
+}
+// .border-bottom {
+//   border-bottom: 1px solid $u-border-color;
+// }
+.icon-wh {
+  width: 36px;
+  height: 36px;
+}
+.jiantou-wh {
+  width: 14px;
+  height: 24px;
+}
+.ml-28 {
+  margin-left: 28px;
+}
 </style>

+ 7 - 1
src/pages/order.vue

@@ -89,7 +89,7 @@ export default {
   },
   computed: {
     userId () {
-      return this.$store.state.userInfo.id
+      return this.$store.state.userInfo.token
     }
   },
   watch: {
@@ -194,6 +194,12 @@ export default {
       })
     },
     toSubmitOrder (e) {
+      if (!this.$store.state.userInfo.alipay_account) {
+        uni.navigateTo({
+          url: '/pagesSub/my/userDetail?toastType=1'
+        })
+        return
+      }
       uni.navigateTo({
         url: `/pagesSub/order/submitOrder?activityId=${e.activity_id}&userActivityId=${e.user_activity_id}`
       })

+ 1 - 1
src/pagesSub/activity/activityDetail.vue

@@ -197,7 +197,7 @@ export default {
   },
   computed: {
     userId () {
-      return this.$store.state.userInfo.id
+      return this.$store.state.userInfo.token
     },
     businessHours () {
       const date = this.$dayjs().format('YYYY年MM月DD日')

+ 56 - 55
src/pagesSub/activity/signUpOutcome.vue

@@ -17,7 +17,8 @@
     </view>
     <view class="btn u-flex u-row-center">
       <button @click="toOrderList">查看订单</button>
-      <button class="active" @click="toOrderMeal">去点餐</button>
+      <button class="active"
+              @click="toOrderMeal">去点餐</button>
     </view>
   </view>
 </template>
@@ -48,63 +49,63 @@ export default {
 </script>
 
 <style lang="scss" scoped>
-  .main {
-    background-color: #FFF;
-    padding-top: 15px;
-  }
-  .success {
-    color:$u-main-color;
-    font-weight: 1000;
-    margin: 48px 0;
+.main {
+  background-color: #fff;
+  padding-top: 15px;
+}
+.success {
+  color: $u-main-color;
+  font-weight: 1000;
+  margin: 48px 0;
+}
+.icon-success-wh {
+  width: 92px;
+  height: 92px;
+  margin-right: 16px;
+}
+.date {
+  font-size: 26px;
+  color: $u-main-color;
+  line-height: 36px;
+  margin: 16px 0 40px 32px;
+  .mtb {
+    margin: 16px 0;
   }
-  .icon-success-wh {
-    width: 92px;
-    height: 92px;
-    margin-right: 16px;
+}
+.message {
+  width: 686px;
+  height: 156px;
+  color: $u-main-color;
+  background-color: #f7f8f9;
+  padding: 24px;
+  border-radius: 8px;
+  .title {
+    font-family: Helvetica;
+    margin-bottom: 8px;
   }
-  .date {
-    font-size: 26px;
-    color:$u-main-color;
-    line-height: 36px;
-    margin: 16px 0 40px 32px;
-    .mtb {
-      margin: 16px 0;
-    }
+  .money {
+    color: #4a6d8d;
   }
-  .message {
-    width: 686px;
-    height: 156px;
-    color:$u-main-color;
-    background-color: #F7F8F9;
-    padding: 24px;
-    border-radius: 8px;
-    .title {
-      font-family: Helvetica;
-      margin-bottom: 8px;
-    }
-    .money {
-      color: #4A6D8D;
-    }
+}
+.btn {
+  button {
+    width: 280px;
+    height: 84px;
+    border: 1px solid #d3d4d5;
+    border-radius: 42px;
+    font-size: 28px;
+    line-height: 40px;
+    color: $u-main-color;
+    background-color: #fff;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+    margin: 40px 0;
   }
-  .btn {
-    button {
-      width: 280px;
-      height: 84px;
-      border: 1px solid #D3D4D5;
-      border-radius: 42px;
-      font-size: 28px;
-      line-height: 40px;
-      color:$u-main-color;
-      background-color: #FFF;
-      display: flex;
-      align-items: center;
-      justify-content: center;
-      margin: 40px 0;
-    }
-    .active {
-      border: 1px solid #FF6632;
-      color: #FF6632;
-      margin-left: 30px;
-    }
+  .active {
+    border: 1px solid #ff6632;
+    color: #ff6632;
+    margin-left: 30px;
   }
+}
 </style>

+ 68 - 27
src/pagesSub/my/userDetail.vue

@@ -1,14 +1,43 @@
+<!--
+ * @Author: your name
+ * @Date: 2021-01-25 11:32:04
+ * @LastEditTime: 2021-01-26 13:33:55
+ * @LastEditors: Please set LastEditors
+ * @Description: In User Settings Edit
+ * @FilePath: \rebatedine-mini\src\pagesSub\my\userDetail.vue
+-->
 <template>
   <view class="main">
     <network-error />
     <view class="item border-bottom u-flex">
       <view class="title bold u-flex-1">头像</view>
-      <image class="avatar" :src="newHead" @click="changeHead"></image>
-      <u-icon name="arrow-right" color="#98999A" size="20"></u-icon>
+      <image class="avatar"
+             :src="newHead"
+             @click="changeHead"></image>
+      <u-icon name="arrow-right"
+              color="#98999A"
+              size="20"></u-icon>
     </view>
     <view class="item border-bottom u-flex u-row-between">
       <view class="title bold">昵称</view>
-      <input class="info u-text-right" v-model="nickName" placeholder="昵称限11字" @change="submit" />
+      <input class="info u-text-right"
+             v-model="nickName"
+             placeholder="昵称限11字"
+             @change="submit" />
+    </view>
+    <view class="item border-bottom u-flex u-row-between">
+      <view class="title bold">支付宝真实姓名</view>
+      <input class="info u-text-right"
+             v-model="alipayUsername"
+             placeholder="支付宝真实姓名"
+             @change="submit" />
+    </view>
+    <view class="item border-bottom u-flex u-row-between">
+      <view class="title bold">支付宝账号</view>
+      <input class="info u-text-right"
+             v-model="alipayAccount"
+             placeholder="支付宝账号"
+             @change="submit" />
     </view>
   </view>
 </template>
@@ -20,7 +49,9 @@ export default {
   data () {
     return {
       newHead: '',
-      nickName: ''
+      nickName: '',
+      alipayAccount: '',
+      alipayUsername: ''
     }
   },
   computed: {
@@ -31,15 +62,25 @@ export default {
       return this.$store.state.imgPrefix
     }
   },
-  onLoad () {
+  onLoad (options) {
     this.newHead = this.userInfo.head_url
     this.nickName = this.userInfo.nick_name
+    this.alipayUsername = this.userInfo.alipay_username
+    this.alipayAccount = this.userInfo.alipay_account
+    if (options.toastType * 1 === 1) {
+      uni.showToast({
+        title: '请先完善支付宝收款账号信息',
+        icon: 'none'
+      })
+    }
   },
   methods: {
     async submit () {
       const params = {
         head_url: this.newHead,
-        nick_name: this.nickName
+        nick_name: this.nickName,
+        alipay_account: this.alipayAccount,
+        alipay_username: this.alipayUsername
       }
       const { code } = await editUserInfo(params)
       if (code === 200) {
@@ -60,27 +101,27 @@ export default {
 </script>
 
 <style lang="scss" scoped>
-  .main {
-    background-color: #FFF;
-    padding: 30px 32px 0 32px;
-  }
-  .item {
-    padding: 40px 0;
-    font-size: 28px;
-    line-height: 40px;
-    .title {
-      color: $u-tips-color;
-    }
-  }
-  .avatar {
-    width: 108px;
-    height: 108px;
-    border-radius: 54px;
-  }
-  .border-bottom {
-    border-bottom: 1px solid #EAEBEC;
-  }
+.main {
+  background-color: #fff;
+  padding: 30px 32px 0 32px;
+}
+.item {
+  padding: 40px 0;
+  font-size: 28px;
+  line-height: 40px;
   .title {
-    font-weight: 1000;
+    color: $u-tips-color;
   }
+}
+.avatar {
+  width: 108px;
+  height: 108px;
+  border-radius: 54px;
+}
+.border-bottom {
+  border-bottom: 1px solid #eaebec;
+}
+.title {
+  font-weight: 1000;
+}
 </style>

+ 22 - 0
src/pagesSub/order/submitOrder.vue

@@ -30,6 +30,24 @@
                type="number"
                placeholder="请输入手机号" />
       </view>
+      <view class="item u-flex u-row-left u-border-bottom">
+        <view class="label u-flex label-w">
+          <view class="icon-bt"></view>
+          <view>支付宝账号</view>
+        </view>
+        <input v-model="userInfo.alipay_account"
+               placeholder="请完善支付宝账号"
+               :disabled="true" />
+      </view>
+      <view class="item u-flex u-row-left u-border-bottom">
+        <view class="label u-flex label-w">
+          <view class="icon-bt"></view>
+          <view>真实姓名</view>
+        </view>
+        <input v-model="userInfo.alipay_username"
+               placeholder="请完善支付宝真实姓名"
+               :disabled="true" />
+      </view>
       <view class="item u-border-bottom">
         <view class="label u-flex">
           <view class="icon-bt"></view>
@@ -121,6 +139,10 @@ export default {
     }
   },
   computed: {
+    userInfo () {
+      console.log(this.$store.state.userInfo)
+      return this.$store.state.userInfo
+    },
     disabledBtn () {
       if (!this.imgList3.length) {
         return true

+ 10 - 2
src/store/index.js

@@ -30,8 +30,11 @@ const store = new Vuex.Store({
       uni.setStorageSync(storageKeys.USER_INFO, state.userInfo)
     },
     changeHeadOrNickName (state, data) {
+      console.log(data)
       state.userInfo.head_url = data.head_url
       state.userInfo.nick_name = data.nick_name
+      state.userInfo.alipay_account = data.alipay_account
+      state.userInfo.alipay_username = data.alipay_username
       uni.setStorageSync(storageKeys.USER_INFO, state.userInfo)
     },
     changeCateId (state, data) {
@@ -85,6 +88,7 @@ const store = new Vuex.Store({
           }
         }
         const userInfo = await wxLogin(params)
+        console.log(userInfo)
         if (userInfo.data) {
           userInfo.data.openid = state.openid
           uni.setStorageSync(storageKeys.USER_TOKEN, userInfo.data.token)
@@ -109,8 +113,12 @@ const store = new Vuex.Store({
           })
           const { code, data, msg } = await bindWxCode({ code: loginData.code })
           if (code === 200) {
-            commit('changeOpenId', data.openid)
-            resolve(data.openid)
+            if (Object.prototype.hasOwnProperty.call(data, 'openid')) {
+              commit('changeOpenId', data.openid)
+              resolve(data.openid)
+            } else {
+              resolve(data)
+            }
           } else {
             uni.showToast({
               icon: 'none',