Prechádzať zdrojové kódy

贵大小程序调整登录与接口

vaecebyZ 1 rok pred
rodič
commit
9a42bf008b

+ 1 - 1
api/common.js

@@ -65,7 +65,7 @@ export function validLogin(data) {
 // 获取手机号
 export function getPhoneNum(data) {
 	return request({
-		url: '/zswl-cloud-bdb/user/getPhoneNum',
+		url: '/zswl-cloud-bdb/user/getPhoneNumGd',
 		data
 	})
 }

+ 1 - 1
components/zs-lazy-load/index.vue

@@ -36,7 +36,7 @@
 			// 占位图片路径
 			loadingImg: {
 				type: String,
-				default: '/static/logo.png'
+				default: '/static/logo.jpg'
 			},
 			// 加载失败的错误占位图
 			errorImg: {

+ 1 - 1
manifest.json

@@ -64,7 +64,7 @@
     "quickapp" : {},
     /* 小程序特有相关 */
     "mp-weixin" : {
-        "appid" : "wx3be1d6d84d46cdf7",
+        "appid" : "wxbc64403830bb13c5",
         "libVersion" : "latest",
         "setting" : {
             "urlCheck" : false,

+ 1 - 1
pages/activity/detail.vue

@@ -8,7 +8,7 @@
     <view class="msg-cover">
       <image
         style="height: 300rpx"
-        src="https://jbm.dev.zonelife.cn/img/15519395654249311.jpg"
+        src="http://jbm.dev.zonelife.cn/img/15519395654249311.jpg"
       ></image>
     </view>
     <view class="main-content">

+ 1 - 1
pages/activity/index.vue

@@ -15,7 +15,7 @@
         <image
           slot="cover"
           class="cover"
-          src="https://jbm.dev.zonelife.cn/img/15519395654249311.jpg"
+          src="http://jbm.dev.zonelife.cn/img/15519395654249311.jpg"
         ></image>
         <view class="content-box">
           <view class="title">期待与生活与“粽”不同</view>

+ 60 - 34
pages/my/index.vue

@@ -2,7 +2,7 @@
   <view class="content">
     <view :style="{ paddingTop: navBarHeight }" class="profile-box">
       <view class="header">
-        <view class="avatar">
+        <view @click="init" class="avatar">
           <image
             :src="userInfo.imgPath || defaultImg"
             mode="aspectFill"
@@ -10,7 +10,7 @@
           />
         </view>
 
-        <view class="info">
+        <view @click="init" class="info">
           <view class="name">
             <text>{{ userInfo.nickname || "用户" }}</text>
           </view>
@@ -33,6 +33,7 @@
       <u-grid-item
         v-for="(baseListItem, baseListIndex) in baseList"
         :key="baseListIndex"
+        @click="jump(baseListItem.path)"
       >
         <!-- <u-icon
           :customStyle="{ paddingTop: 20 + 'rpx' }"
@@ -47,14 +48,13 @@
         <text class="grid-text">{{ baseListItem.title }}</text>
       </u-grid-item>
     </u-grid>
-    <view
-      style="font-size: 34rpx; font-weight: bold; margin: 30rpx 0 0 30rpx"
-    >
+    <view style="font-size: 34rpx; font-weight: bold; margin: 30rpx 0 0 30rpx">
       常用功能
     </view>
     <view class="setting">
       <u-cell-group :border="false">
         <u-cell
+          @click="jump(item.path)"
           class="setting-cell"
           v-for="item in settingList"
           :rightIconStyle="{ fontSize: '15px' }"
@@ -88,11 +88,13 @@ export default {
           name: "order",
           title: "全部",
           src: "/static/icon/my/all.png",
+          path: "../../my/order/index",
         },
         {
           name: "red-packet",
           title: "待付款",
           src: "/static/icon/my/obligations.png",
+          path: "../../my/order/index?type=WAIT_PAYMENT",
         },
         {
           name: "car",
@@ -108,6 +110,7 @@ export default {
           name: "rmb-circle",
           title: "退款",
           src: "/static/icon/my/refund.png",
+          path: "../../my/order/index?type=APPLY_REFUND",
         },
       ],
       settingList: [
@@ -115,6 +118,7 @@ export default {
         {
           name: "vip",
           title: "会员码",
+          path:'../../my/memberCenter/index'
         },
         {
           name: "location",
@@ -135,42 +139,64 @@ export default {
     this.navBarHeight = this.$navHight();
   },
   onShow() {
-    if (uni.getStorageSync("token")) {
-      this.getUserDetail();
-    } else {
-      (this.userInfo = {
-        imgPath: null,
-        lastLogin: "",
-        level: null,
-        nickname: null,
-        openId: "",
-        phoneNum: "",
-        sex: 0,
-        userId: "",
-        valid: 0,
-      }),
-        uni.showModal({
+    init();
+  },
+  methods: {
+    init() {
+      if (uni.getStorageSync("token")) {
+        this.getUserDetail();
+      } else {
+        (this.userInfo = {
+          imgPath: null,
+          lastLogin: "",
+          level: null,
+          nickname: null,
+          openId: "",
+          phoneNum: "",
+          sex: 0,
+          userId: "",
+          valid: 0,
+        }),
+          uni.showModal({
+            title: "请登录",
+            confirmText: "去登录",
+            success(res) {
+              console.log(res);
+              if (res.confirm) {
+                uni.navigateTo({
+                  url: "../../login/login/login",
+                });
+              }
+            },
+          });
+      }
+    },
+    // 获取用户详情
+    getUserDetail() {
+      getUserDetail().then((res) => {
+        if (res.state == "Success") {
+          this.userInfo = res.content;
+          uni.setStorageSync("userInfo", JSON.stringify(this.userInfo));
+        }
+      });
+    },
+    jump(url) {
+      if (!uni.getStorageSync("token")) {
+        return uni.showModal({
           title: "请登录",
           confirmText: "去登录",
           success(res) {
             console.log(res);
             if (res.confirm) {
               uni.navigateTo({
-                url: "../../login/login/login",
+                url: "../../login/login/login?redirect=/pages/my/index",
               });
             }
           },
         });
-    }
-  },
-  methods: {
-    // 获取用户详情
-    getUserDetail() {
-      getUserDetail().then((res) => {
-        if (res.state == "Success") {
-          this.userInfo = res.content;
-          uni.setStorageSync("userInfo", JSON.stringify(this.userInfo));
-        }
+      }
+      uni.navigateTo({
+        url,
       });
     },
   },
@@ -184,7 +210,7 @@ page {
 <style lang="scss" scoped>
 .content {
   .profile-box {
-    background: url("https://jbm.dev.zonelife.cn/img/background.png") no-repeat;
+    background: url("http://jbm.dev.zonelife.cn/img/background.png") no-repeat;
     background-size: 100% 100%;
     overflow: hidden;
     border-bottom-left-radius: 40% 5%;
@@ -238,7 +264,7 @@ page {
     padding: 20rpx;
     height: 80rpx;
     color: white;
-    background: url("https://jbm.dev.zonelife.cn/img/vip.png") no-repeat;
+    background: url("http://jbm.dev.zonelife.cn/img/vip.png") no-repeat;
     background-size: 100% 100%;
     border-radius: 10px 10px 0 0;
 
@@ -280,7 +306,7 @@ page {
     margin-left: 20rpx;
     width: 90%;
     height: 80rpx;
-    background-color: rgba( #000000, .2);
+    background-color: rgba(#000000, 0.2);
     color: black;
     padding-left: 30rpx;
     line-height: 80rpx;

BIN
static/icon/my/background.png


BIN
static/level0.png


BIN
static/level1.png


BIN
static/level2.png


BIN
static/level3.png


BIN
static/logo.jpg


BIN
static/logo.png


BIN
static/test-card-bg.png


BIN
static/top-bg.png


BIN
static/water-banner.png


BIN
static/water-bg.png


+ 3 - 3
study/community/detail.vue

@@ -121,7 +121,7 @@
 				status: 'noMore',
 				list:[
 					{
-						head:require('../../static/logo.png'),
+						head:require('../../static/logo.jpg'),
 						userName:'李老师',
 						content:'继续加油哦,看好你!',
 						createTime:'2023-08-29 21:13:56 ',
@@ -155,7 +155,7 @@
 			send(val){
 				console.log(val);
 				this.list.push({
-						head:require('../../static/logo.png'),
+						head:require('../../static/logo.jpg'),
 						userName:'李老师',
 						content:val.detail.value,
 						createTime:uni.$u.timeFormat(new Date(), 'yyyy-mm-dd hh:MM:ss'),
@@ -196,7 +196,7 @@
 			if(JSON.stringify(eventChannel) !=='{}'){
 				eventChannel.on('detail', function(data) {
 					that.info.userName = '官方'
-					that.info.head = data.publishLogo || require('../../static/logo.png')
+					that.info.head = data.publishLogo || require('../../static/logo.jpg')
 					
 				})
 			}

+ 1 - 1
study/index.vue

@@ -63,7 +63,7 @@
 						{{item.communityTitle}}
 					</view>
 					<view class="user-info">
-						<image class="head" :src="require('@/static/logo.png')||item.publishLogo" mode=""></image>
+						<image class="head" :src="require('@/static/logo.jpg')||item.publishLogo" mode=""></image>
 						<view class="user-name">
 							{{item.publishUser|| "官方"}}
 						</view>

+ 2 - 2
study/type.vue

@@ -55,7 +55,7 @@
 								{{item.courseName}}
 							</view>
 							<view class="user-info">
-								<image class="head" src="../static/logo.png" mode=""></image>
+								<image class="head" src="../static/logo.jpg" mode=""></image>
 								<view class="user-name">
 									研学官方账号
 								</view>
@@ -73,7 +73,7 @@
 								{{item.courseName}}
 							</view>
 							<view class="user-info">
-								<image class="head" src="../static/logo.png" mode=""></image>
+								<image class="head" src="../static/logo.jpg" mode=""></image>
 								<view class="user-name">
 									研学官方账号
 								</view>

+ 103 - 100
utils/request.js

@@ -2,113 +2,116 @@
 // const BASE_URL = 'http://192.168.110.153:9002'
 // const BASE_URL = 'https://zswl.api.jpy.wang/zswl-cloud-bdb'
 // const BASE_URL = 'https://api.dev.zonelife.cn'
-import {
-	BASE_URL
-} from '@/utils/config.js'
+import { BASE_URL } from "@/utils/config.js";
+
+let errorCount = 0;
+const MAX_ERROR_COUNT = 2;
 
 //封装请求方法
 export const request = (options) => {
-	return new Promise((resolve, reject) => {
-			//请求路径拼接,,其中options.url就是通过下面方法myRequest获取到接口部分的url
-			//method--请求方法,不是method的post就是get
-			//请求的参数,当没有参数的时候就是空对象
-			// BASE_URL = BASE_UR.includes('dev') ? 
-			let BASE_URL2 = BASE_URL;
-			if(options.url.includes('/zswl-cloud-shop')){
-				BASE_URL2 = 'http://g3710170f8.zicp.fun'
-				options.url =	options.url.replace("/zswl-cloud-shop","")
-			}
-
-			uni.request({
-					url: BASE_URL2 + options.url,
-					method: options.method || 'GET',
-					data: options.data || {},
-					header: {
-						accessToken: uni.getStorageSync('token')
-					},
-					success: (res) => {
-						
-						if (res.statusCode !== 200) {
-
-							return uni.showToast({
-								title: '获取失败'
-							})
-
-							// uni.hideLoading()
-						} else if (res.data.msg != '成功') { //接口返回报错
-
-							uni.showToast({
-								title: res.data.content || res.data.msg || res.data.exception.message || '请求失败',
-								icon: 'error'
-							})
-
-							console.log('报错:', res);
+  return new Promise((resolve, reject) => {
+    //请求路径拼接,,其中options.url就是通过下面方法myRequest获取到接口部分的url
+    //method--请求方法,不是method的post就是get
+    //请求的参数,当没有参数的时候就是空对象
+    // BASE_URL = BASE_UR.includes('dev') ?
+    let BASE_URL2 = BASE_URL;
+    // if(options.url.includes('/zswl-cloud-shop')){
+    // 	BASE_URL2 = 'http://g3710170f8.zicp.fun'
+    // 	options.url =	options.url.replace("/zswl-cloud-shop","")
+    // }
 
-							// token过期或出了问题
-							if (res.data.exception && res.data.exception.type ==
-								'AuthenticationCredentialsNotFoundException')
-								 {
+    uni.request({
+      url: BASE_URL2 + options.url,
+      method: options.method || "GET",
+      data: options.data || {},
+      header: {
+        accessToken: uni.getStorageSync("token"),
+      },
+      success: (res) => {
+        if (res.statusCode !== 200) {
+          return uni.showToast({
+            title: "获取失败",
+          });
 
-									uni.showLoading({
-										title: '刷新登录中',
-									})
+          // uni.hideLoading()
+        } else if (res.data.msg != "成功") {
+          //接口返回报错
 
-								if (!uni.getStorageSync('refreshToken')) {
-									uni.clearStorageSync()
-									uni.reLaunch({
-										url: '/pages/index/index'
-									})
-								}
+          uni.showToast({
+            title:
+              res.data.content ||
+              res.data.msg ||
+              res.data.exception.message ||
+              "请求失败",
+            icon: "error",
+          });
 
-								// 刷新token
-								uni.request({
-										url: BASE_URL + '/zswl-cloud-bdb/user/refreshToken',
-										method: 'GET',
-										data: {
-											refreshToken: uni.getStorageSync('refreshToken')
-										},
-										success(r) {
-											uni.hideLoading()
-											if (r.data.content == '刷新令牌错误') {
-												uni.showToast({
-													title: '登录失效',
-													icon: 'fail'
-												})
-												uni.clearStorageSync()
-												uni.reLaunch({
-													url: '/pages/index/index'
-												})
-											} else {
-												
-												uni.setStorageSync('token', r.data.content) //登录状态
-												// 刷新页面
-												let list = ['/pay/pay']
-												var pages = getCurrentPages();
-												var url = '/' + pages[pages.length - 1].route
-												if(list.indexOf(url) == -1){
-													console.log(11111111,list.indexOf(url),url);
-													uni.reLaunch({
-														url
-													})
-												}
-												
-										}
-									}
-								})
+          console.log("报错:", res);
 
-						}
+          // token过期或出了问题
+          if (
+            res.data.exception &&
+            res.data.exception.type ==
+              "AuthenticationCredentialsNotFoundException"
+          ) {
+            uni.showLoading({
+              title: "刷新登录中",
+            });
+            if (errorCount <= MAX_ERROR_COUNT) {
+              console.log("errorCount", errorCount);
+              errorCount++;
+              if (!uni.getStorageSync("refreshToken")) {
+                uni.clearStorageSync();
+                uni.reLaunch({
+                  url: "/pages/index/index",
+                });
+              }
 
-					}
+              // 刷新token
+              uni.request({
+                url: BASE_URL + "/zswl-cloud-bdb/user/refreshToken",
+                method: "GET",
+                data: {
+                  refreshToken: uni.getStorageSync("refreshToken"),
+                },
+                success(r) {
+                  uni.hideLoading();
+                  if (r.data.content == "刷新令牌错误") {
+                    uni.showToast({
+                      title: "登录失效",
+                      icon: "fail",
+                    });
+                    uni.clearStorageSync();
+                    uni.reLaunch({
+                      url: "/pages/index/index",
+                    });
+                  } else {
+                    uni.setStorageSync("token", r.data.content); //登录状态
+                    // 刷新页面
+                    let list = ["/pay/pay"];
+                    var pages = getCurrentPages();
+                    var url = "/" + pages[pages.length - 1].route;
+                    if (list.indexOf(url) == -1) {
+                      uni.reLaunch({
+                        url,
+                      });
+                    }
+                  }
+                },
+              });
+            }
+          }
+        }
 
-					resolve(res.data)
-				},
-				//请求失败
-				fail: (err) => {
-					uni.showToast({
-						title: '请求接口失败'
-					})
-					reject(err)
-				}
-			})
-	})
-}
+        resolve(res.data);
+      },
+      //请求失败
+      fail: (err) => {
+        uni.showToast({
+          title: "请求接口失败",
+        });
+        reject(err);
+      },
+    });
+  });
+};