tangning 10 tháng trước cách đây
mục cha
commit
973c3bd0f9

+ 2 - 1
src/App.vue

@@ -57,7 +57,8 @@ export default {
       console.log(res)
       this.$store.dispatch('wx/initJssdk',res.data)
       })
-  },
+      this.$store.dispatch('home/getUserInfo', this.getRequest)
+    },
   methods: {
     async getWinxinCodeFun(huiyi_id){//获得微信code
             var self=this;

+ 8 - 2
src/api/request.js

@@ -1,6 +1,7 @@
 import axios from 'axios'
 import router from '../router/index'
 import { Toast } from 'vant';
+const wx = window.wx;
 import store from '../store/index';
 axios.defaults.withCredentials = false;
 axios.defaults.headers.common['token'] = store.state.home.token || window.localStorage.getItem("token");
@@ -26,10 +27,15 @@ axios.interceptors.request.use(function (config) {
 // 添加一个响应拦截器
 axios.interceptors.response.use(function (response) {
   if (response.data && response.data.code) {
-    if (response.data.message === 'token失效' || response.data.message === '请求头中没有token') {
+    if (response.data.code == 5001 || response.data.code == 5002 || response.data.msg === 'redis token is null') {
       //未登录
       Toast.fail("登录信息已失效,请重新登录");
-      router.push('/login');
+      console.log(wx, "登录信息已失效,请重新登录");
+      setTimeout(() => {
+      wx.miniProgram.navigateTo({
+        url: '/pages/home/index'
+      })
+      }, 500)
     }
     if (parseInt(response.data.code) === -1) {
       Toast.fail(response.data.msg);

+ 4 - 3
src/components/tabbar/index.vue

@@ -270,9 +270,10 @@ export default {
             that.codeImg = obj[result];
             // that.$store.commit("changeActive", index);
             if(!that.codeListok.includes(result)){
-              Bus.emit('handleItem', result)
-              that.getRequest('/api/wx/clockIn', {code: result})
-              that.getloadlist()
+              that.getRequest('/api/wx/clockIn', {code: result}).then(res => {
+                Bus.emit('handleItem', result)
+                that.getloadlist()
+              })
             }
           }
         });

+ 10 - 9
src/pages/composite/index.vue

@@ -67,8 +67,7 @@
         </div>
       </div> -->
       </div>
-      <div class="shareImg" v-if="img">
-        <div class="close" @click="shareImg = false
+      <div class="close" @click="shareImg = false
         showShare = false
         imgUrl = ''
         fileList = []
@@ -79,6 +78,7 @@
                   src="/static/img/icon_cancel@2x.png"
                 ></img>
               </div>
+      <div class="shareImg" v-if="img">
         <img style="width: 100%" :src="img" alt="" />
         <div class="tips" style="text-align: center; color: #fff; margin-top: 10px">
           长按保存图片
@@ -479,14 +479,15 @@ export default {
     position: absolute;
     left: 0;
     top: 0;
-    .close{
+  }
 
-      position: absolute;
-      right: -0;
-      top: -0;
-      width: 42px;
-      height: 42px;
-    }
+  .close {
+    position: absolute;
+    right: -0;
+    top: -0;
+    width: 42px;
+    height: 42px;
+    z-index: 11;
   }
   .shareImgDiv {
     width: calc(100vw - 40px);

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

@@ -43,7 +43,7 @@
           </div>
       </div>
     </div>
-    <tabbar />
+    <!-- <tabbar /> -->
     <!-- <div class="fixed bottom-40 flex w-full justify-around" style="">
       <div class="text-center">
         点亮祈福

+ 1 - 1
src/pages/prayers/clocked.vue

@@ -2,7 +2,7 @@
   <div class="clockedPage">
     <div class="clocked" v-if="!checkLight">
       <div class="tips" style="padding-top: 138px;">
-      完成至少6处扫码打卡
+      {{codeList.length>5?'请选择莲花灯进行祈愿':'完成至少6处扫码打卡'}}
     </div>
     <div class="xzlp">
       <div class="list">

+ 18 - 6
src/pages/prayers/showlist.vue

@@ -30,7 +30,7 @@
     <div class="content-scroll swiper">
       <!-- 使用swiper -->
       <div class="swiper-wrapper">
-      <swiper :options="swiperoption" ref="mySwiper">
+      <swiper :options="swiperoption" ref="mySwiper"  @slideChange="slideChanged">
             <swiper-slide class="swiper-slide scroll-item list active" v-for="(item,index) in list" :key="item.id" :class="
               current == index
                 ? `active index${index} ${curIndex == index ? 'fang' : ''}`
@@ -73,8 +73,8 @@
       </div>
       <div class="tips">
         请选择祈愿类型
-        <div v-if="curIndex" class="downButtom flex justify-center">
-          <div class="downButtomItem">返回我的祈愿</div>
+        <div v-if="mycurrentData.id != userInfo.id" class="downButtom flex justify-center">
+          <div class="downButtomItem" @click="swiper.slideTo(mycurrent, 100, true)">返回我的祈愿</div>
         </div>
         <div v-else class="downButtom flex justify-center">
           <div class="downButtomItem" @click="$router.push('/map')">祈愿地图</div>
@@ -159,6 +159,10 @@ export default {
       shareShow: false,
       scrollLeft: 0, // 横向滚动条位置
       current: 0,
+      mycurrent: 0,
+      mycurrentData: {
+
+      },
       curIndex: null,
       qrcode1: null,
       qrcode2: null,
@@ -194,7 +198,7 @@ export default {
     }
   },
   computed: {
-    ...mapState('home', ['img']),
+    ...mapState('home', ['img', "userInfo"]),
     swiper() {
       return this.$refs.mySwiper.swiper
     }
@@ -202,8 +206,11 @@ export default {
   mounted() {
     this.$store.commit('home/setImg', null)
     this.getRequest('/api/show/pray/getList').then(res => {
-      console.log(res, 'getList')
-      this.list = res.data
+      this.list = res.data || []
+      this.mycurrent = res.data.findIndex(item => item.id == this.userInfo.id)
+      this.$nextTick(() => {
+        this.swiper.slideTo(this.mycurrent, 100, true)
+      })
     })
   },
   methods: {
@@ -260,6 +267,11 @@ export default {
         }
       })
     },
+    slideChanged() {
+      console.log('slideChanged', this.swiper)
+      let active = this.swiper.activeIndex
+      this.mycurrentData = this.list[active]
+     },
     // 获取标题区域宽度,和每个子元素节点的宽度以及元素距离左边栏的距离
     getScrollW() {
       const query = uni.createSelectorQuery().in(this)

+ 11 - 1
src/store/module/home/index.js

@@ -1,10 +1,12 @@
 import html2canvas from 'html2canvas'
+// import { POST, GET } from '@/api/request';
 
 const userInfoModule = {
   namespaced: true,
   state: () => ({
     active: null,
     img: null,
+    userInfo: {},
     token: localStorage.getItem('token') || null,
   }),
   mutations: {
@@ -15,7 +17,9 @@ const userInfoModule = {
       state.token = token
       localStorage.setItem('token', token)
       console.log('route', token)
-
+    },
+    setUserInfo(state, userInfo){
+      state.userInfo = userInfo
     },
     sendMessage (state, payload) {
       uniWebview.postMessage({
@@ -27,6 +31,12 @@ const userInfoModule = {
     }
   },
   actions: {
+    getUserInfo({ commit }, getRequest) {
+      getRequest('/api/wx/userInfo').then((res) => {
+        console.log('getUserInfo', res);
+        commit('setUserInfo', res.data)
+      })
+    },
     //保存图片
     saveImage(context, refs) {
       console.log('saveImage', refs);