xiaohaizhao 1 рік тому
батько
коміт
972494c6af

+ 2 - 1
app.json

@@ -16,7 +16,8 @@
     "pages/bankAccount/index",
     "pages/bankAccount/update",
     "pages/notifications/webview",
-    "pages/notifications/associatedPublicNumber"
+    "pages/notifications/associatedPublicNumber",
+    "pages/login/developerTools"
   ],
   "subpackages": [
     {

+ 60 - 0
pages/login/developerTools.js

@@ -0,0 +1,60 @@
+let _Http = getApp().globalData.http
+Page({
+    data: {
+        verification: false,
+        password: ""
+    },
+    onLoad(options) {
+        if (_Http.ENV != 'develop') {
+            this.setData({
+                verification: true
+            })
+        } else {
+            this.init();
+        }
+    },
+    init() {
+        this.setData({
+            runtimeEnvironment: _Http.ENV == 'develop' ? '开发环境' : '生产环境',
+            "baseUrl": _Http.baseUrl,
+            urls: _Http.urls,
+            verification: false
+        })
+    },
+    onInput(e) {
+        this.setData({
+            password: e.detail
+        })
+    },
+    enterInto() {
+        if (this.data.password != 'jxys@12345') return wx.showToast({
+            title: '密码错误',
+            icon: "none"
+        })
+        this.init()
+    },
+    onChange({
+        detail
+    }) {
+        console.log(detail)
+        let that = this;
+        wx.showModal({
+            title: '提示',
+            content: `是否确定将服务地址修改为“${detail}”?`,
+            complete: (res) => {
+                if (res.cancel) that.setData({
+                    baseUrl: that.data.baseUrl
+                })
+                if (res.confirm) {
+                    that.setData({
+                        baseUrl: detail
+                    })
+                    _Http.baseUrl = detail;
+                    wx.showToast({
+                        title: '修改成功',
+                    })
+                }
+            }
+        })
+    }
+})

+ 8 - 0
pages/login/developerTools.json

@@ -0,0 +1,8 @@
+{
+  "usingComponents": {
+      "van-radio": "@vant/weapp/radio/index",
+      "van-radio-group": "@vant/weapp/radio-group/index",
+      "van-field": "@vant/weapp/field/index"
+  },
+  "navigationBarTitleText": "开发者工具"
+}

+ 17 - 0
pages/login/developerTools.scss

@@ -0,0 +1,17 @@
+.box {
+	width: 720rpx;
+	margin: 0 auto;
+	margin-top: 12rpx;
+}
+
+.group {
+	border: 1px solid #333;
+	border-radius: 8rpx;
+	padding: 20rpx;
+	box-sizing: border-box;
+}
+
+.radio {
+	font-size: 14px;
+	margin-top: 12rpx;
+}

+ 24 - 0
pages/login/developerTools.wxml

@@ -0,0 +1,24 @@
+<block wx:if="{{verification}}">
+    <van-field value="{{ password }}" type="password" placeholder="请输入管理密码" border="{{ false }}" bind:change="onInput" use-button-slot>
+        <van-button slot="button" disabled='{{!password}}' size="small" type="primary" bindtap="enterInto">
+            进入
+        </van-button>
+    </van-field>
+</block>
+
+<block wx:else>
+    <view class="box">
+        运行环境:{{runtimeEnvironment}}
+    </view>
+
+    <view class="box">
+        服务地址:{{baseUrl}}
+    </view>
+
+    <view class="box group">
+        切换服务地址
+        <van-radio-group value="{{ baseUrl }}" bind:change="onChange">
+            <van-radio custom-class='radio' wx:for="{{urls}}" wx:key="name" name="{{item.url}}">{{item.name}}:{{item.url}}</van-radio>
+        </van-radio-group>
+    </view>
+</block>

+ 14 - 0
pages/login/phone.js

@@ -15,6 +15,9 @@ Page({
         if (wx.getStorageSync('isAgree')) this.setData({
             isAgree: wx.getStorageSync('isAgree')
         })
+        this.setData({
+            devCount: 0
+        })
     },
     /* 微信登录 */
     wechatLogin() {
@@ -63,5 +66,16 @@ Page({
             isAgree: detail
         })
     },
+
+    todev() {
+        if (this.data.devCount == 5) {
+            wx.navigateTo({
+                url: '/pages/login/developerTools',
+            })
+            this.data.devCount = 0;
+        } else {
+            this.data.devCount += 1;
+        }
+    },
     onShareAppMessage() {}
 })

+ 2 - 2
pages/login/phone.wxml

@@ -1,5 +1,5 @@
 <view class="logo">
-    <image src="/static/image/logo.png" />
+    <image src="/static/image/logo.png" bindtap="todev" />
 </view>
 
 <!-- 手机号登录/账号登录  -->
@@ -14,7 +14,7 @@
 <Agreement isAgree='{{isAgree}}' bindcallBack='agreementChange' />
 
 <!-- 快捷登录 -->
-<block >
+<block>
     <view style="height: 100rpx;" />
     <van-divider contentPosition="center">其他登录方式</van-divider>
     <view style="width: 100%; text-align: center;">

+ 12 - 5
utils/Http.js

@@ -1,13 +1,20 @@
 class HTTP {
 	constructor() {
-		let ENV = wx.getAccountInfoSync().miniProgram.envVersion;
-		if (ENV === 'release') { // 正式版
-			// this.baseUrl = "https://lsa.cnyunl.com";
+		this.ENV = wx.getAccountInfoSync().miniProgram.envVersion;
+		this.urls = [{
+			name: "云链E订单",
+			url: "https://www.cnyunl.com"
+		}, {
+			name: "楚楚",
+			url: "https://cucu.cnyunl.com:8079"
+		}, {
+			name: "开发环境",
+			url: "http://61.164.207.46:8200"
+		}]
+		if (this.ENV === 'release') { // 正式版
 			this.baseUrl = "https://www.cnyunl.com";
 		} else {
-			// this.baseUrl = "https://www.cnyunl.com";
 			this.baseUrl = "http://61.164.207.46:8200";
-			// this.baseUrl = "https://cucu.cnyunl.com:8079";
 		}
 		console.log("接口地址:", this.baseUrl)
 	}