Pārlūkot izejas kodu

添加用户协议

zs 1 gadu atpakaļ
vecāks
revīzija
04d5d6642b

+ 12 - 0
pages.json

@@ -32,6 +32,12 @@
 			"style": {
 				"navigationBarTitleText": "个人中心"
 			}
+		},
+		{
+			"path": "pages/login/index",
+			"style": {
+				"navigationBarTitleText": "登录"
+			}
 		}
 	],
 	"subPackages": [ //分包配置
@@ -43,6 +49,12 @@
 					"style": {
 						"navigationBarTitleText": "test"
 					}
+				},
+				{
+					"path": "other/agree",
+					"style": {
+						"navigationBarTitleText": "用户协议"
+					}
 				}
 			]
 		},

+ 163 - 0
pages/login/index.vue

@@ -0,0 +1,163 @@
+<template>
+	<view class="main">
+		<view class="wx">
+			<view class="wx_1">
+				<text class="iconfont icon-weixin"></text>
+			</view>
+			<view class="wx_2">
+				<button size="mini" @tap="otherLogin()">微信信任登录</button>
+			</view>
+			<view class="wx_3">
+				<checkbox-group @change="changeAgree">
+					<label>
+						<checkbox :checked="agree" />
+						<text @tap.stop="toAgree()">我已阅读并同意“用户协议”和“隐私政策”</text>
+					</label>
+				</checkbox-group>
+			</view>
+		</view>
+	</view>
+</template>
+<script>
+	export default {
+		data() {
+			return {
+				// 用户协议
+				agree: false,
+				// 注册账号信息
+				user: {},
+			};
+		},
+		onShow: function() {
+			const that = this;
+			// 查询平台信息
+			that.searchOpenids();
+		},
+		methods: {
+			async searchOpenids() {
+				const that = this;
+				uni.getStorage({
+					key: 'openid',
+					success: function(res) {
+						that.$set(that, `openid`, res.data);
+					},
+					fail: function(err) {
+						uni.login({
+							success: async function(res) {
+								if (res.code) {
+									const aee = await that.$app('/wechat/api/login/app',
+									'GET', {
+										js_code: res.code,
+										config: that.$config.wx_projectkey
+									})
+									if (aee.errcode == '0') {
+										uni.setStorage({
+											key: "openid",
+											data: aee.data.openid
+										})
+										that.$set(that, `openid`, aee.data.openid);
+									} else {
+										uni.showToast({
+											title: aee.errmsg,
+											icon: 'none'
+										})
+									}
+								} else {
+									uni.showToast({
+										title: res.errMsg,
+										icon: 'none'
+									})
+								}
+							}
+						});
+					}
+				})
+			},
+			// 其他登录方式
+			async otherLogin() {
+				const that = this;
+				let agree = that.agree;
+				let openid = that.openid;
+				if (agree) {
+					if (openid) {
+						const aee = await that.$api(`/login/wxapp/${openid}`, 'POST', {})
+						if (aee.errcode == '0') {
+							uni.reLaunch({
+								url: `/pages/home/index`
+							})
+						} else {
+							uni.showToast({
+								title: aee.errmsg,
+								icon: 'none'
+							})
+						}
+					} else {
+						uni.showToast({
+							title: '系统更新中,请稍后再试!',
+							icon: 'none'
+						})
+					}
+				} else {
+					uni.showToast({
+						title: '请阅读并同意用户协议和隐私政策',
+						icon: 'none'
+					})
+				}
+			},
+			// 同意隐私协议
+			changeAgree() {
+				const that = this;
+				let agree = !that.agree
+				that.$set(that, `agree`, agree);
+			},
+			// 查看隐私协议
+			toAgree() {
+				const that = this;
+				uni.navigateTo({
+					url: `/pagesHome/other/agree`
+				})
+			},
+		},
+	}
+</script>
+
+<style lang="scss" scoped>
+	.main {
+		display: flex;
+		flex-direction: column;
+		width: 100vw;
+		height: 100vh;
+
+		.wx {
+			text-align: center;
+			margin: 25vw 0 0 0;
+
+			.wx_1 {
+				margin: 0 0 5vw 0;
+
+				.iconfont {
+					color: var(--f35BColor);
+				}
+
+				text {
+					font-size: 50px;
+				}
+			}
+
+			.wx_2 {
+				button {
+					background: var(--f35BColor);
+					color: var(--fffColor);
+					font-size: var(--font16Size);
+				}
+			}
+
+			.wx_3 {
+				position: absolute;
+				bottom: 10vw;
+				text-align: center;
+				font-size: 12px;
+			}
+		}
+	}
+</style>

+ 69 - 0
pagesHome/other/agree.vue

@@ -0,0 +1,69 @@
+<template>
+	<mobile-frame>
+		<view class="main">
+			<view class="one">
+				<rich-text :nodes="formatRichText(info.agreement)"></rich-text>
+			</view>
+		</view>
+	</mobile-frame>
+</template>
+
+<script>
+	export default {
+		components: {},
+		data() {
+			return {
+				info: {}
+			};
+		},
+		onShow: function() {
+			const that = this;
+			that.search();
+		},
+		methods: {
+			search() {
+				const that = this;
+				try {
+					const res = uni.getStorageSync('config');
+					if (res) that.$set(that, `info`, res);
+				} catch (err) {
+					uni.showToast({
+						title: err.errmsg,
+						icon: 'error',
+						duration: 2000
+					});
+				}
+			},
+			// 处理富文本
+			formatRichText(html) {
+				if (html) {
+					// 富文本内容格式化
+					return html && html.replace(/<img[^>]*>/gi, function(match, capture) {
+						// 查找所有的 img 元素
+						return match.replace(/style=".*"/gi, '').replace(/style='.*'/gi,
+							'')
+						// 删除找到的所有 img 元素中的 style 属性
+					}).replace(/\<img/gi, '<img style="width:100%;"') // 对 img 元素增加 style 属性,并设置宽度为 100%
+				}
+			},
+		}
+	}
+</script>
+
+<style lang="scss">
+	.main {
+		display: flex;
+		flex-direction: column;
+		width: 100vw;
+		height: 100vh;
+
+		.one {
+			padding: 2vw;
+
+			.rich-img {
+				width: 100% !important;
+				display: block;
+			}
+		}
+	}
+</style>

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 1 - 1
unpackage/dist/dev/.sourcemap/mp-weixin/common/vendor.js.map


Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 1 - 0
unpackage/dist/dev/.sourcemap/mp-weixin/pages/login/index.js.map


Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 1 - 0
unpackage/dist/dev/.sourcemap/mp-weixin/pagesHome/other/agree.js.map


+ 4 - 2
unpackage/dist/dev/mp-weixin/app.json

@@ -3,13 +3,15 @@
     "pages/index/index",
     "pages/home/index",
     "pages/science/index",
-    "pages/my/index"
+    "pages/my/index",
+    "pages/login/index"
   ],
   "subPackages": [
     {
       "root": "pagesHome",
       "pages": [
-        "index/index"
+        "index/index",
+        "other/agree"
       ]
     },
     {

+ 10 - 0
unpackage/dist/dev/mp-weixin/common/vendor.js

@@ -20167,6 +20167,11 @@ var _default = {
     "style": {
       "navigationBarTitleText": "个人中心"
     }
+  }, {
+    "path": "pages/login/index",
+    "style": {
+      "navigationBarTitleText": "登录"
+    }
   }],
   "subPackages": [{
     "root": "pagesHome",
@@ -20175,6 +20180,11 @@ var _default = {
       "style": {
         "navigationBarTitleText": "test"
       }
+    }, {
+      "path": "other/agree",
+      "style": {
+        "navigationBarTitleText": "用户协议"
+      }
     }]
   }, {
     "root": "pagesScience",

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 365 - 0
unpackage/dist/dev/mp-weixin/pages/login/index.js


+ 4 - 0
unpackage/dist/dev/mp-weixin/pages/login/index.json

@@ -0,0 +1,4 @@
+{
+  "navigationBarTitleText": "登录",
+  "usingComponents": {}
+}

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 1 - 0
unpackage/dist/dev/mp-weixin/pages/login/index.wxml


+ 34 - 0
unpackage/dist/dev/mp-weixin/pages/login/index.wxss

@@ -0,0 +1,34 @@
+@charset "UTF-8";
+/* 水平间距 */
+/* 水平间距 */
+.main.data-v-4586967a {
+  display: flex;
+  flex-direction: column;
+  width: 100vw;
+  height: 100vh;
+}
+.main .wx.data-v-4586967a {
+  text-align: center;
+  margin: 25vw 0 0 0;
+}
+.main .wx .wx_1.data-v-4586967a {
+  margin: 0 0 5vw 0;
+}
+.main .wx .wx_1 .iconfont.data-v-4586967a {
+  color: var(--f35BColor);
+}
+.main .wx .wx_1 text.data-v-4586967a {
+  font-size: 50px;
+}
+.main .wx .wx_2 button.data-v-4586967a {
+  background: var(--f35BColor);
+  color: var(--fffColor);
+  font-size: var(--font16Size);
+}
+.main .wx .wx_3.data-v-4586967a {
+  position: absolute;
+  bottom: 10vw;
+  text-align: center;
+  font-size: 12px;
+}
+

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 236 - 0
unpackage/dist/dev/mp-weixin/pagesHome/other/agree.js


+ 4 - 0
unpackage/dist/dev/mp-weixin/pagesHome/other/agree.json

@@ -0,0 +1,4 @@
+{
+  "navigationBarTitleText": "用户协议",
+  "usingComponents": {}
+}

+ 1 - 0
unpackage/dist/dev/mp-weixin/pagesHome/other/agree.wxml

@@ -0,0 +1 @@
+<mobile-frame vue-id="026690e3-1" bind:__l="__l" vue-slots="{{['default']}}"><view class="main"><view class="one"><rich-text nodes="{{$root.m0}}"></rich-text></view></view></mobile-frame>

+ 17 - 0
unpackage/dist/dev/mp-weixin/pagesHome/other/agree.wxss

@@ -0,0 +1,17 @@
+@charset "UTF-8";
+/* 水平间距 */
+/* 水平间距 */
+.main {
+  display: flex;
+  flex-direction: column;
+  width: 100vw;
+  height: 100vh;
+}
+.main .one {
+  padding: 2vw;
+}
+.main .one .rich-img {
+  width: 100% !important;
+  display: block;
+}
+