谢杰标 vor 2 Jahren
Ursprung
Commit
881f122546

+ 16 - 8
common/httpList/login.js

@@ -1,9 +1,9 @@
 import {
 	myRequest
 } from '../request.js'
-import store from '@/store/index.js'    
+import store from '@/store/index.js'
 export default {
-	
+
 	//我的列表数据
 	getinfoAttached(data) {
 		return myRequest({
@@ -42,8 +42,8 @@ export default {
 			noToken: true
 		})
 	},
-	
-	
+
+
 	//刷新令牌
 	refreshToken(data) {
 		return myRequest({
@@ -62,9 +62,9 @@ export default {
 	},
 	refreshUserInfo() {
 		this.getInfo().then(resdata => {
-			if(resdata.data.code == 200){
-			store.commit('updateUserInfo',{userInfo:resdata.data.data})
-			}	
+			if (resdata.data.code == 200) {
+				store.commit('updateUserInfo', { userInfo: resdata.data.data })
+			}
 		});
 	},
 	//注册短信
@@ -85,7 +85,7 @@ export default {
 			noToken: true
 		})
 	},
-	
+
 	//重新绑定手机
 	bindNewTel(data) {
 		return myRequest({
@@ -149,6 +149,14 @@ export default {
 			noToken: true
 		})
 	},
+	skipLogin(data) {
+		return myRequest({
+			url: '/app/common/telphone_login',
+			method: 'post',
+			data: data,
+			noToken: true
+		})
+	},
 	//绑定身份证号信息
 	bindId(data) {
 		return myRequest({

+ 93 - 75
common/methodTool.js

@@ -52,7 +52,7 @@ export default {
 
 	},
 	setUuid(id) {
-		uni.setStorageSync('uuid',id)
+		uni.setStorageSync('uuid', id)
 	},
 
 	getUuid() {
@@ -71,36 +71,36 @@ export default {
 	 * @param timestamp
 	 * @returns {*}
 	 */
-	timestampToTime(timestamp, isDay = true,hasChinese, line ) {
+	timestampToTime(timestamp, isDay = true, hasChinese, line) {
 		if (!timestamp) {
 			return ''
 		}
 		var date = new Date(timestamp * 1000); //时间戳为10位需*1000,时间戳为13位的话不需乘1000
 		var Y = date.getFullYear() + (hasChinese ? '' : '-');
 		var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + (hasChinese ? '' : '-');
-		var D = date.getDate() < 10 ? '0' + date.getDate() + (hasChinese ? '' : ' ') : date.getDate() + (hasChinese ? '' :' ');
+		var D = date.getDate() < 10 ? '0' + date.getDate() + (hasChinese ? '' : ' ') : date.getDate() + (hasChinese ? '' : ' ');
 		var h = date.getHours() < 10 ? '0' + date.getHours() + ':' : date.getHours() + ':';
 		var m = date.getMinutes() < 10 ? '0' + date.getMinutes() + ':' : date.getMinutes() + ':';
 		var s = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
 		if (isDay) {
-			
-			if(hasChinese) {
-				return Y +'年'+ M +'月'+ D + '日';
+
+			if (hasChinese) {
+				return Y + '年' + M + '月' + D + '日';
 			} else {
 				return Y + M + D;
 			}
-			
+
 		}
 		if (line) {
 			return h + m + s
 		}
-		
-		if(hasChinese) {
-			return Y +'年'+ M +'月'+ D + '日' + h + m + s;
+
+		if (hasChinese) {
+			return Y + '年' + M + '月' + D + '日' + h + m + s;
 		} else {
 			return Y + M + D + h + m + s;
 		}
-		
+
 	},
 	// 时间戳转换日期
 	formDate(time, formate = 'yyyy-mm-dd hh:mm:ss') {
@@ -109,7 +109,7 @@ export default {
 			return va
 		}
 		if (time) {
-			
+
 			var value = new Date(time * 1000); //时间戳为10位需*1000,时间戳为13位的话不需乘1000
 			// var value = new Date(parseFloat(time))
 			var year = value.getFullYear()
@@ -121,7 +121,7 @@ export default {
 			let res = ''
 			switch (formate) {
 				case 'mm-dd': {
-					res =  month + '-' + day
+					res = month + '-' + day
 					break
 				}
 				case 'yyyy-mm-dd': {
@@ -171,7 +171,7 @@ export default {
 		var NowTime = new Date(); //当前时间
 		//后台给我的是10位 精确到秒的 所有下面我就除以了1000,不要小数点后面的
 		var t = EndTime - (NowTime.getTime() / 1000).toFixed(0);
-		
+
 		if (t <= 0) {
 			return '已结束'
 		}
@@ -222,13 +222,13 @@ export default {
 							quality: 75,
 							width: '35%',
 							height: '35%',
-							success:async rest => {
+							success: async rest => {
 								const waitUpload = await self.uploadFile(rest.tempFilePath, 0);
-						console.log(waitUpload,'waitUpload')
+								console.log(waitUpload, 'waitUpload')
 								resolve(waitUpload);
 							}
 						});
-					} else if(canvasWidth > 1000 || canvasHeight > 1000){
+					} else if (canvasWidth > 1000 || canvasHeight > 1000) {
 						uni.compressImage({
 							src: url,
 							quality: 75,
@@ -236,13 +236,13 @@ export default {
 							height: '50%',
 							success: async rest => {
 								const waitUpload = await self.uploadFile(rest.tempFilePath, 0);
-						console.log(waitUpload,'waitUpload')
+								console.log(waitUpload, 'waitUpload')
 								resolve(waitUpload);
 							}
 						});
 					} else {
 						const waitUpload = await self.uploadFile(url, 0);
-						console.log(waitUpload,'waitUpload')
+						console.log(waitUpload, 'waitUpload')
 						resolve(waitUpload);
 						// console.log('无需压缩', url);
 						// resolve(url);
@@ -282,7 +282,7 @@ export default {
 					},
 					success: result => {
 						// if (result.statusCode === 200) {
-							resolve(ossToken.dir);
+						resolve(ossToken.dir);
 						// } else {
 						// 	uni.showToast({
 						// 		title: '上传失败',
@@ -343,69 +343,87 @@ export default {
 		}
 		return returnAge; //返回周岁年龄
 	},
-	getDate () {
-	  let nowDate = new Date()
-	  let date = {
-	    year: nowDate.getFullYear(),
-	    month: nowDate.getMonth() + 1,
-	    date: nowDate.getDate()
-	  }
-	  return  date.year + '-' + date.month + '-' + date.date
+	getDate() {
+		let nowDate = new Date()
+		let date = {
+			year: nowDate.getFullYear(),
+			month: nowDate.getMonth() + 1,
+			date: nowDate.getDate()
+		}
+		return date.year + '-' + date.month + '-' + date.date
+	},
+	getZeroTime() {
+		return Number(new Date(new Date().toLocaleDateString()).getTime() / 1000)
 	},
-	getZeroTime () {
-		return Number(new Date(new Date().toLocaleDateString()).getTime()/1000)
+	setClock: function (time) {
+		var that = this, sec = parseInt(time), clockCount = {}, strTimer = "";
+		clockCount = setInterval(function () {
+			if (sec == 0) {
+				$(".js-count-down").html("活动已经结束");
+				clearInterval(clockCount);
+				return false;
+			}
+			strTimer = that.secondToDate(sec);
+			$(".js-count-down").html(strTimer);
+			sec--;
+		}, 1000)
 	},
-	setClock:function(time){
-	            	var that=this, sec= parseInt(time) , clockCount={}, strTimer="";
-	            	    clockCount=setInterval(function(){
-	            	    	if(sec==0){
-			                        $(".js-count-down").html("活动已经结束");
-			                       clearInterval(clockCount);
-			                       return false;
-	                        }
-						    strTimer = that.secondToDate(sec);
-						    $(".js-count-down").html(strTimer);
-						    sec--;
-	                    },1000)
-	            },
-	secondToDate(result){
-		var h = Math.floor(result / 3600) < 10 ? '0'+Math.floor(result / 3600) : Math.floor(result / 3600);
+	secondToDate(result) {
+		var h = Math.floor(result / 3600) < 10 ? '0' + Math.floor(result / 3600) : Math.floor(result / 3600);
 		var m = Math.floor((result / 60 % 60)) < 10 ? '0' + Math.floor((result / 60 % 60)) : Math.floor((result / 60 % 60));
 		var s = Math.floor((result % 60)) < 10 ? '0' + Math.floor((result % 60)) : Math.floor((result % 60));
-			if(h==0){
-				result = m + ":" + s;
-			}else{
-				result = h+':'+m + ":" + s
-			}
+		if (h == 0) {
+			result = m + ":" + s;
+		} else {
+			result = h + ':' + m + ":" + s
+		}
 		return result;
-	 },
-	 /**
-      * 
-      * @param {int} result 
-      * @returns {string}
-      * @remard 单位S转小时分钟秒
-      */
-     secondToTime(result,Diszing = true) {
-         var h = Math.floor(result / 3600) < 10 ? '0' + Math.floor(result / 3600) : Math.floor(result / 3600);
-         var m = Math.floor((result / 60 % 60)) < 10 ? '0' + Math.floor((result / 60 % 60)) : Math.floor((result / 60 % 60));
-         var s = Math.floor((result % 60)) < 10 ? '0' + Math.floor((result % 60)) : Math.floor((result % 60));
-         if (h == 0 && Diszing) {
-             result = m + ":" + s;
-         } else {
-             result = h + ':' + m + ":" + s
-         }
-         return result;
-     },
+	},
+	/**
+	 * 
+	 * @param {int} result 
+	 * @returns {string}
+	 * @remard 单位S转小时分钟秒
+	 */
+	secondToTime(result, Diszing = true) {
+		var h = Math.floor(result / 3600) < 10 ? '0' + Math.floor(result / 3600) : Math.floor(result / 3600);
+		var m = Math.floor((result / 60 % 60)) < 10 ? '0' + Math.floor((result / 60 % 60)) : Math.floor((result / 60 % 60));
+		var s = Math.floor((result % 60)) < 10 ? '0' + Math.floor((result % 60)) : Math.floor((result % 60));
+		if (h == 0 && Diszing) {
+			result = m + ":" + s;
+		} else {
+			result = h + ':' + m + ":" + s
+		}
+		return result;
+	},
 	/**
 	 * @param {Object} length  长度
 	 * 获取随机字符串
 	 */
 	getRandomString(length) {
-	   var str = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
-	   var result = '';
-	   for (var i = length; i > 0; --i) 
-		 result += str[Math.floor(Math.random() * str.length)];
-	   return result;
-	 },
-	 
+		var str = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
+		var result = '';
+		for (var i = length; i > 0; --i)
+			result += str[Math.floor(Math.random() * str.length)];
+		return result;
+	},
+	skipLogin(sign) {
+		return api.skipLogin({ sign }).then(res => {
+			if (res.data.code == 200) {
+				uni.removeStorageSync('newUser_sc')
+				uni.removeStorageSync('shareActivityCode')
+				//信息完善,直接进入页面
+				uni.setStorageSync('user_account', res.data.data.user_account);
+				uni.setStorageSync('token', res.data.data.token);
+				store.dispatch('getUserInfo').finally(e => {
+					return Promise.resolve()
+				})
+			} else {
+				uni.navigateTo({
+					url: '/pages4/login/login'
+				});
+				return Promise.reject()
+			}
+		})
+	}
 }

+ 2 - 2
common/request.js

@@ -7,11 +7,11 @@ var num = 1
 //接口api   
 // export const BASE_URL = 'https://api.xyyxt.net'   //release
 // export const BASE_URL = 'https://test.xyyxt.net'   //预发布
-export const BASE_URL = 'http://120.79.166.78:19012' // 测试环境
+// export const BASE_URL = 'http://120.79.166.78:19012' // 测试环境
 // export const BASE_URL = 'http://42.192.164.187:19005'    //test(后端本地)
 // export const BASE_URL = 'http://192.168.1.222:5055'    //后端本地更新到222
 // export const BASE_URL = 'http://192.168.1.24:5055'    //后端本地
-// export const BASE_URL = 'http://192.168.1.7:5055'    //后端本地
+export const BASE_URL = 'http://192.168.1.7:5055'    //后端本地
 
  //图片上传api
 // export const BASE_IMG_URL = 'https://file.xyyxt.net/'     //release

+ 33 - 15
package-lock.json

@@ -1,57 +1,75 @@
 {
   "name": "zz-applet",
   "version": "1.0.0",
-  "lockfileVersion": 1,
+  "lockfileVersion": 3,
   "requires": true,
-  "dependencies": {
-    "@babel/runtime": {
+  "packages": {
+    "": {
+      "name": "zz-applet",
+      "version": "1.0.0",
+      "license": "ISC",
+      "dependencies": {
+        "jweixin-module": "^1.6.0",
+        "tki-qrcode": "^0.1.6",
+        "uview-ui": "^1.8.3",
+        "vconsole": "^3.15.0"
+      }
+    },
+    "node_modules/@babel/runtime": {
       "version": "7.20.6",
       "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.20.6.tgz",
       "integrity": "sha512-Q+8MqP7TiHMWzSfwiJwXCjyf4GYA4Dgw3emg/7xmwsdLJOZUp+nMqcOwOzzYheuM1rhDu8FSj2l0aoMygEuXuA==",
-      "requires": {
+      "dependencies": {
         "regenerator-runtime": "^0.13.11"
+      },
+      "engines": {
+        "node": ">=6.9.0"
       }
     },
-    "copy-text-to-clipboard": {
+    "node_modules/copy-text-to-clipboard": {
       "version": "3.0.1",
       "resolved": "https://registry.npmjs.org/copy-text-to-clipboard/-/copy-text-to-clipboard-3.0.1.tgz",
-      "integrity": "sha512-rvVsHrpFcL4F2P8ihsoLdFHmd404+CMg71S756oRSeQgqk51U3kicGdnvfkrxva0xXH92SjGS62B0XIJsbh+9Q=="
+      "integrity": "sha512-rvVsHrpFcL4F2P8ihsoLdFHmd404+CMg71S756oRSeQgqk51U3kicGdnvfkrxva0xXH92SjGS62B0XIJsbh+9Q==",
+      "engines": {
+        "node": ">=12"
+      }
     },
-    "core-js": {
+    "node_modules/core-js": {
       "version": "3.26.1",
       "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.26.1.tgz",
-      "integrity": "sha512-21491RRQVzUn0GGM9Z1Jrpr6PNPxPi+Za8OM9q4tksTSnlbXXGKK1nXNg/QvwFYettXvSX6zWKCtHHfjN4puyA=="
+      "integrity": "sha512-21491RRQVzUn0GGM9Z1Jrpr6PNPxPi+Za8OM9q4tksTSnlbXXGKK1nXNg/QvwFYettXvSX6zWKCtHHfjN4puyA==",
+      "hasInstallScript": true
     },
-    "jweixin-module": {
+    "node_modules/jweixin-module": {
       "version": "1.6.0",
       "resolved": "https://registry.npmjs.org/jweixin-module/-/jweixin-module-1.6.0.tgz",
       "integrity": "sha512-dGk9cf+ipipHmtzYmKZs5B2toX+p4hLyllGLF6xuC8t+B05oYxd8fYoaRz0T30U2n3RUv8a4iwvjhA+OcYz52w=="
     },
-    "mutation-observer": {
+    "node_modules/mutation-observer": {
       "version": "1.0.3",
       "resolved": "https://registry.npmjs.org/mutation-observer/-/mutation-observer-1.0.3.tgz",
       "integrity": "sha512-M/O/4rF2h776hV7qGMZUH3utZLO/jK7p8rnNgGkjKUw8zCGjRQPxB8z6+5l8+VjRUQ3dNYu4vjqXYLr+U8ZVNA=="
     },
-    "regenerator-runtime": {
+    "node_modules/regenerator-runtime": {
       "version": "0.13.11",
       "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz",
       "integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg=="
     },
-    "tki-qrcode": {
+    "node_modules/tki-qrcode": {
       "version": "0.1.6",
       "resolved": "https://registry.npmjs.org/tki-qrcode/-/tki-qrcode-0.1.6.tgz",
       "integrity": "sha512-EnnlS8psowC7PsW3MDYcxvJYkuklX3WAZ/BYanR4TdBHTu74GfjTBX8Y16REP+AeDENiVtBPh4jtTRL2P736hQ=="
     },
-    "uview-ui": {
+    "node_modules/uview-ui": {
       "version": "1.8.3",
       "resolved": "https://registry.npmjs.org/uview-ui/-/uview-ui-1.8.3.tgz",
       "integrity": "sha512-DqKc+qRrOZLPcyfWv4b0HspSS9n1Cd6BbgKiYEv9rjTAnWoqJV7rXsvWqZdr5iKGP5EMNbNS741GLNw4sIHbpw=="
     },
-    "vconsole": {
+    "node_modules/vconsole": {
       "version": "3.15.0",
       "resolved": "https://registry.npmjs.org/vconsole/-/vconsole-3.15.0.tgz",
       "integrity": "sha512-8hq7wabPcRucSWQyN7/1tthMawP9JPvM95zgtMHpPknMMMCKj+abpoK7P7oKK4B0qw58C24Mdvo9+raUdpHyVQ==",
-      "requires": {
+      "dependencies": {
         "@babel/runtime": "^7.17.2",
         "copy-text-to-clipboard": "^3.0.1",
         "core-js": "^3.11.0",

+ 0 - 1
package.json

@@ -8,7 +8,6 @@
     "uview-ui": "^1.8.3",
     "vconsole": "^3.15.0"
   },
-  "devDependencies": {},
   "scripts": {
     "test": "echo \"Error: no test specified\" && exit 1"
   },

+ 41 - 38
pages/index/index.vue

@@ -319,7 +319,7 @@
         </template>
       </view>
     </view>
-	<!-- #ifdef MP-WEIXIN -->
+    <!-- #ifdef MP-WEIXIN -->
     <view :style="{ opacity: opacitys }" class="officials">
       <view class="weixin_official_account">
         <image class="off_logo" src="/static/index/official.png"></image>
@@ -339,7 +339,7 @@
         </view>
       </view>
     </view>
-	<!-- #endif -->
+    <!-- #endif -->
   </view>
 </template>
 
@@ -445,25 +445,25 @@ export default {
     });
   },
   async onShow() {
-	// #ifdef H5
-	if (location.search) {
-    console.log('url值:', location.search)
-		let arrs = location.search.slice(1).split("&")
-		for (let i = 0; i < arrs.length; i++) {
-			this.optObj[arrs[i].split('=')[0]] = arrs[i].split('=')[1]
-		}
-		console.log('获取的optObj:', this.optObj);
-		uni.setStorageSync('h5_code', this.optObj.code)
-		this.OfficialLogin()
-	} else {
-		console.log('没有code')
-		// 没有code,就重定向到地址https://www.xyyxt.net?ask_type=h.xyyxt.net 去获取code,授权后就会把code带上然后访问域名,就拿到code了
-		// if (!uni.getStorageSync('h5_code')) {
-		// 	location.replace('https://www.xyyxt.net/?ask_type=h.xyyxt.net')
-		// 	return
-		// }
-	}
-	// #endif
+    // #ifdef H5
+    if (location.search) {
+      console.log("url值:", location.search);
+      let arrs = location.search.slice(1).split("&");
+      for (let i = 0; i < arrs.length; i++) {
+        this.optObj[arrs[i].split("=")[0]] = arrs[i].split("=")[1];
+      }
+      console.log("获取的optObj:", this.optObj);
+      uni.setStorageSync("h5_code", this.optObj.code);
+      this.OfficialLogin();
+    } else {
+      console.log("没有code");
+      // 没有code,就重定向到地址https://www.xyyxt.net?ask_type=h.xyyxt.net 去获取code,授权后就会把code带上然后访问域名,就拿到code了
+      // if (!uni.getStorageSync('h5_code')) {
+      // 	location.replace('https://www.xyyxt.net/?ask_type=h.xyyxt.net')
+      // 	return
+      // }
+    }
+    // #endif
     this.getInfo(); // 判断有没有关注公众号
     this.isClickOff(); //关注公众号,每天最多显示1次;当天学员关闭弹窗后,无需再显示
     uni.removeStorageSync("goPath");
@@ -560,23 +560,23 @@ export default {
   },
   methods: {
     ...mapActions(["getUserInfo", "appCommonConfig"]),
-	// 公众号登录
-	OfficialLogin() {
-		console.log('公众号登录');
-		this.$http({
-			url: '/app/common/gzh_login',
-			method: 'post',
-			data: {
-				code: this.optObj.code
-			},
-			noToken: true
-		}).then((res) => {
-			if (res.data.code == 200) {
-			} else {
-				this.$u.toast(res.data.msg)
-			}
-		})
-	},
+    // 公众号登录
+    OfficialLogin() {
+      console.log("公众号登录");
+      this.$http({
+        url: "/app/common/gzh_login",
+        method: "post",
+        data: {
+          code: this.optObj.code,
+        },
+        noToken: true,
+      }).then((res) => {
+        if (res.data.code == 200) {
+        } else {
+          this.$u.toast(res.data.msg);
+        }
+      });
+    },
     tobuy(item) {
       if (item.goodsType == 2) {
         uni.navigateTo({
@@ -594,6 +594,9 @@ export default {
       }
     },
     getInfo() {
+      if (!this.$method.isLogin()) {
+        return;
+      }
       // /app/user/getInfo 登录用户信息 // fromPlat来源平台 1小程序 2PC网站
       this.$api.getInfo({ fromPlat: 1 }).then((res) => {
         if (res.data.code == 200) {

+ 8 - 2
pages/questionBank/index.vue

@@ -104,13 +104,19 @@ export default {
 				pageSize: 10
 			},
 			total: 0,
+			options:{}
 		}
 	},
 	computed: {
 		...mapGetters(['userInfo']),
 	},
-	onLoad() {},
-	onShow() {
+	onLoad(options) {
+		this.options = option
+	},
+	async onShow() {
+		if (this.option.skipPort) {
+           await this.$method.skipLogin(this.option.skipPort)
+        }
 		this.param.pageNum = 1
 		this.questionLists = []
 		this.getBankList()

+ 4 - 1
pages3/live/detail.vue

@@ -812,10 +812,13 @@ export default {
     }
 
   },
-  onShow() {
+ async onShow() {
     // this.photoPopup = true;
     // this.isTaking = true;
     console.log('this.options:', this.options);
+    if (this.option.skipPort) {
+      await this.$method.skipLogin(this.option.skipPort)
+    }
     if (this.$method.isGoLogin()) { // 从公众号消息进来的没登录需要跳到登录页,登录后返回
       return;
     }

+ 1 - 18
pages3/polyv/detail.vue

@@ -958,10 +958,8 @@ export default {
   },
   async onShow() {
     if (this.option.skipPort) {
-      let aa = await this.telphoneLogin()
-      console.log('---aa', aa);
+      await this.$method.skipLogin(this.option.skipPort)
     }
-    console.log('===onshow');
     if (this.$method.isGoLogin()) {
       // 从公众号消息进来的没登录需要跳到登录页,登录后返回
       return;
@@ -982,21 +980,6 @@ export default {
   mounted() {},
   methods: {
     ...mapMutations(["updateChapterOpen", "updateLiveLast"]),
-    // 手机号码自动登入
-    telphoneLogin() {
-      return this.$http({
-        url: "/app/common/telphone_login",
-        method: "post",
-        data: { sign: this.option.skipPort },
-        noToken: true
-      }).then((res) => {
-        return Promise.resolve(res)
-        if (res.data.code == 200) {
-          
-          console.log('手机号码自动登入');
-        }
-      });
-    },
     // 新增微信公众号模板消息点击数据
     clickOfficial() {
       this.$http({