Jelajahi Sumber

fix

很好 优化得乱七八糟的 有问题问宋飞扬
songfeiyang 1 tahun lalu
induk
melakukan
0a7e825369

+ 200 - 181
src/pages.json

@@ -1,182 +1,201 @@
 {
-	"easycom": {
-		"^u-(.*)": "uview-ui/components/u-$1/u-$1.vue"
-	},
-	"pages": [{
-			"path": "pages/index",
-			"style": {
-				"navigationBarTitleText": "开屏广告",
-				"navigationStyle": "custom"
-			}
-		},
-		{
-			"path": "pages/tabbar/home/index",
-			"style": {
-				"navigationBarTitleText": "首页",
-				"navigationStyle": "custom"
-			}
-		},
-		{
-			"path": "pages/tabbar/community/index",
-			"style": {
-				"navigationBarTitleText": "社区",
-				"navigationStyle": "custom"
-			}
-		},
-		{
-			"path": "pages/tabbar/message/index",
-			"style": {
-				"navigationBarTitleText": "消息",
-				"navigationStyle": "custom"
-			}
-		},
-		{
-			"path": "pages/tabbar/mine/index",
-			"style": {
-				"navigationBarTitleText": "我的",
-				"navigationStyle": "custom"
-			}
-		},
-		{
-			"path": "pages/login/index",
-			"style": {
-				"navigationBarTitleText": "登录"
-			}
-		},
-		{
-			"path": "pages/login/phoneLogin",
-			"style": {
-				"navigationBarTitleText": "手机验证"
-			}
-		}
-	],
-	"subPackages": [{
-			"root": "pages/business",
-			"pages": [{
-					"path": "category",
-					"style": {
-						"navigationBarTitleText": "商家分类"
-					}
-				},
-				{
-					"path": "service/detail",
-					"style": {
-						"navigationBarTitleText": "服务详情"
-					}
-				},
-				{
-					"path": "list",
-					"style": {
-						"navigationBarTitleText": "商家列表"
-					}
-				},
-				{
-					"path": "detail",
-					"style": {
-						"navigationBarTitleText": "商家详情"
-					}
-				},
-				{
-					"path": "service/list",
-					"style": {
-						"navigationBarTitleText": "服务列表"
-					}
-				}
-			]
-		},
-		{
-			"root": "pages/user",
-			"pages": [{
-					"path": "collect/list",
-					"style": {
-						"navigationBarTitleText": "我的收藏"
-					}
-				},
-				{
-					"path": "appoint/index",
-					"style": {
-						"navigationBarTitleText": "预约列表"
-					}
-				},
-				{
-					"path": "coupon/index",
-					"style": {
-						"navigationBarTitleText": "优惠券"
-					}
-				},
-				{
-					"path": "score/index",
-					"style": {
-						"navigationBarTitleText": "我的积分"
-					}
-				},
-				{
-					"path": "info/index",
-					"style": {
-						"navigationBarTitleText": "个人中心"
-					}
-				},
-				{
-					"path": "info/update",
-					"style": {
-						"navigationBarTitleText": "编辑资料"
-					}
-				},
-				{
-					"path": "settings/index",
-					"style": {
-						"navigationBarTitleText": "设置"
-					}
-				}
-			]
-		},
-		{
-			"root": "pages/order",
-			"pages": [
-				{
-					"path": "order",
-					"style": {
-						"navigationBarTitleText": "提价订单"
-					}
-				}
-			]
-		}
-	],
-	"tabBar": {
-		"color": "#999999",
-		"selectedColor": "#42b2fa",
-		"borderStyle": "black",
-		"backgroundColor": "#ffffff",
-		"list": [{
-				"text": "首页",
-				"pagePath": "pages/tabbar/home/index",
-				"iconPath": "static/images/home.png",
-				"selectedIconPath": "static/images/home-select.png"
-			},
-			{
-				"pagePath": "pages/tabbar/community/index",
-				"text": "社区",
-				"iconPath": "static/images/community.png",
-				"selectedIconPath": "static/images/community-select.png"
-			},
-			{
-				"pagePath": "pages/tabbar/message/index",
-				"text": "消息",
-				"iconPath": "static/images/message.png",
-				"selectedIconPath": "static/images/message-select.png"
-			},
-			{
-				"pagePath": "pages/tabbar/mine/index",
-				"text": "我的",
-				"iconPath": "static/images/mine.png",
-				"selectedIconPath": "static/images/mine-select.png"
-			}
-		]
-	},
-	"globalStyle": {
-		"navigationBarTextStyle": "black",
-		"navigationBarTitleText": "uni-app",
-		"navigationBarBackgroundColor": "#F8F8F8",
-		"backgroundColor": "#F8F8F8"
-	}
-}
+  "easycom": {
+    "^u-(.*)": "uview-ui/components/u-$1/u-$1.vue"
+  },
+  "pages": [
+    {
+      "path": "pages/index",
+      "style": {
+        "navigationBarTitleText": "开屏广告",
+        "navigationStyle": "custom"
+      }
+    },
+    {
+      "path": "pages/tabbar/home/index",
+      "style": {
+        "navigationBarTitleText": "首页",
+        "navigationStyle": "custom"
+      }
+    },
+    {
+      "path": "pages/tabbar/community/index",
+      "style": {
+        "navigationBarTitleText": "社区",
+        "navigationStyle": "custom"
+      }
+    },
+    {
+      "path": "pages/tabbar/message/index",
+      "style": {
+        "navigationBarTitleText": "消息",
+        "navigationStyle": "custom"
+      }
+    },
+    {
+      "path": "pages/tabbar/mine/index",
+      "style": {
+        "navigationBarTitleText": "我的",
+        "navigationStyle": "custom"
+      }
+    },
+    {
+      "path": "pages/login/register",
+      "style": {
+        "navigationBarTitleText": "注册",
+        "navigationStyle": "custom"
+      }
+    },
+    {
+      "path": "pages/common/search/index",
+      "name": "搜索",
+      "style": {
+        "navigationBarTitleText": "搜索"
+      }
+    },
+    {
+      "path": "pages/login/index",
+      "style": {
+        "navigationBarTitleText": "登录"
+      }
+    },
+    {
+      "path": "pages/login/phoneLogin",
+      "style": {
+        "navigationBarTitleText": "账号登录"
+      }
+    }
+  ],
+  "subPackages": [
+    {
+      "root": "pages/business",
+      "pages": [
+        {
+          "path": "category",
+          "style": {
+            "navigationBarTitleText": "商家分类"
+          }
+        },
+        {
+          "path": "service/detail",
+          "style": {
+            "navigationBarTitleText": "服务详情"
+          }
+        },
+        {
+          "path": "list",
+          "style": {
+            "navigationBarTitleText": "商家列表"
+          }
+        },
+        {
+          "path": "detail",
+          "style": {
+            "navigationBarTitleText": "商家详情"
+          }
+        },
+        {
+          "path": "service/list",
+          "style": {
+            "navigationBarTitleText": "服务列表"
+          }
+        }
+      ]
+    },
+    {
+      "root": "pages/user",
+      "pages": [
+        {
+          "path": "collect/list",
+          "style": {
+            "navigationBarTitleText": "我的收藏"
+          }
+        },
+        {
+          "path": "appoint/index",
+          "style": {
+            "navigationBarTitleText": "预约列表"
+          }
+        },
+        {
+          "path": "coupon/index",
+          "style": {
+            "navigationBarTitleText": "优惠券"
+          }
+        },
+        {
+          "path": "score/index",
+          "style": {
+            "navigationBarTitleText": "我的积分"
+          }
+        },
+        {
+          "path": "info/index",
+          "style": {
+            "navigationBarTitleText": "个人中心"
+          }
+        },
+        {
+          "path": "info/update",
+          "style": {
+            "navigationBarTitleText": "编辑资料"
+          }
+        },
+        {
+          "path": "settings/index",
+          "style": {
+            "navigationBarTitleText": "设置"
+          }
+        }
+      ]
+    },
+    {
+      "root": "pages/order",
+      "pages": [
+        {
+          "path": "order",
+          "style": {
+            "navigationBarTitleText": "提价订单"
+          }
+        }
+      ]
+    }
+  ],
+  "tabBar": {
+    "color": "#999999",
+    "selectedColor": "#42b2fa",
+    "borderStyle": "black",
+    "backgroundColor": "#ffffff",
+    "list": [
+      {
+        "text": "首页",
+        "pagePath": "pages/tabbar/home/index",
+        "iconPath": "static/images/home.png",
+        "selectedIconPath": "static/images/home-select.png"
+      },
+      {
+        "pagePath": "pages/tabbar/community/index",
+        "text": "社区",
+        "iconPath": "static/images/community.png",
+        "selectedIconPath": "static/images/community-select.png"
+      },
+      {
+        "pagePath": "pages/tabbar/message/index",
+        "text": "消息",
+        "iconPath": "static/images/message.png",
+        "selectedIconPath": "static/images/message-select.png"
+      },
+      {
+        "pagePath": "pages/tabbar/mine/index",
+        "text": "我的",
+        "iconPath": "static/images/mine.png",
+        "selectedIconPath": "static/images/mine-select.png"
+      }
+    ]
+  },
+  "globalStyle": {
+    "navigationBarTextStyle": "black",
+    "navigationBarTitleText": "uni-app",
+    "navigationBarBackgroundColor": "#F8F8F8",
+    "backgroundColor": "#F8F8F8"
+  }
+}

+ 15 - 0
src/pages/login/index.vue

@@ -18,6 +18,18 @@ html
       >
     </view>
     <br />
+    <view style="display: flex">
+      <u-icon name="gift-fill" color="#2979ff" size="28"></u-icon>
+      <text @click="userAgreementClick" style="font-weight: bold"
+        >随便看看</text
+      >
+      <u-icon name="gift-fill" color="#2979ff" size="28"></u-icon>
+      <text @click="userAgreementClick" style="font-weight: bold"
+        >联系客服</text
+      >
+    </view>
+    <br />
+    <br />
     <view style="font-size: 12px">
       温馨提示:登录前请详细阅读
       <text @click="userAgreementClick" style="font-weight: bold"
@@ -73,6 +85,9 @@ export default {
     //点击用户协议
     userAgreementClick() {},
 
+    //点击忘记密码
+    forgetPassword() {},
+
     //点击隐私政策
     privacyPolicyClick() {},
   },

+ 45 - 34
src/pages/login/phoneLogin.vue

@@ -8,43 +8,26 @@
         :rules="rules"
         ref="loginForm"
       >
-        <u-form-item prop="mobile" borderBottom>
+        <u-form-item prop="mobile" borderBottom label="账号">
           <u-input
             v-model="loginForm.mobile"
             maxlength="11"
             border="none"
-            placeholder="请输入手机号"
+            focus
+            placeholder="请输入账号/手机号"
           >
-            <template slot="prefix">
-              <view class="phone-prefix">
-                <text>+86</text>
-                <u-icon name="arrow-down-fill"></u-icon>
-              </view>
-            </template>
           </u-input>
         </u-form-item>
-        <u-form-item prop="captcha" borderBottom>
+        <u-form-item prop="captcha" label="密码" borderBottom>
           <u-input
-            v-model="loginForm.captcha"
+            v-model="loginForm.password"
             maxlength="6"
             border="none"
-            placeholder="请输入短信验证码"
+            placeholder="请输入码"
           >
-            <template slot="suffix">
-              <u-code
-                ref="uCode"
-                :seconds="seconds"
-                changeText="X秒后重新获取"
-                end-text="重新获取"
-                start-text="获取验证码"
-                @change="codeChange"
-                :keep-running="true"
-              ></u-code>
-              <u--text :text="tips" @tap="getCode" type="primary"></u--text>
-            </template>
           </u-input>
         </u-form-item>
-        <view class="phone-question">手机号无法使用</view>
+        <view class="phone-question" @click="forgetPassword">忘记密码?</view>
         <u-form-item>
           <u-button
             type="primary"
@@ -55,6 +38,11 @@
             >登录</u-button
           >
         </u-form-item>
+        <u-form-item>
+          <u-button :loading="loading" shape="circle" @click="register"
+            >注册</u-button
+          >
+        </u-form-item>
       </u--form>
       <view class="user-agreement">
         <u-checkbox-group>
@@ -74,13 +62,23 @@
     </view>
 
     <view>
-      <u-popup :show="show" @close="close" mode="bottom">
-        <view>
+      <u-popup :show="show" @close="close" mode="center">
+        <view
+          style="
+            height: 100rpx;
+            width: 700rpx;
+            align-items: center;
+            display: flex;
+            justify-content: center;
+          "
+        >
           <text style="color: gray; font-size: 14px">我已阅读并同意</text>
           <text style="font-weight: bold">《用户协议》</text>
           <text style="font-weight: bold">《隐私政策》</text>
         </view>
-        <u-button class="confirm-button" @click="confirmShow">确认</u-button>
+        <u-button @click="confirmShow" type="primary" :loading="loading"
+          >确认</u-button
+        >
       </u-popup>
     </view>
   </view>
@@ -88,7 +86,6 @@
 
 <script>
 import { getSmsCodeByPhone, loginByPhoneAndSmsCode } from '@/api/login';
-
 export default {
   data() {
     return {
@@ -97,8 +94,9 @@ export default {
         client_secret: 'qWBe6jD%GCuPPTkP',
         grant_type: 'sms',
         token: '',
-        mobile: '18888888888',
-        captcha: '363636',
+        mobile: '', //手机号
+        captcha: '363636', //验证码
+        password: '', //密码
       },
       rules: {
         mobile: [
@@ -130,14 +128,17 @@ export default {
       loading: false,
     };
   },
+
   onReady() {
     this.$refs.loginForm.setRules(this.rules);
   },
+
   computed: {
     isDisabled() {
       return !(this.loginForm.mobile && this.loginForm.captcha.length === 6);
     },
   },
+
   methods: {
     getCode() {
       if (!this.loginForm.mobile) return uni.$u.toast('请输入您的手机号!');
@@ -159,12 +160,13 @@ export default {
           });
       }
     },
+
+    //点击登录
     async login() {
       if (!this.isChecked) {
         this.show = true;
         return;
       }
-
       this.loading = true;
       loginByPhoneAndSmsCode(this.loginForm)
         .then(res => {
@@ -183,20 +185,29 @@ export default {
           uni.$u.toast('登录失败-' + err.data.error_description);
         });
     },
-    codeChange(text) {
-      this.tips = text;
+
+    //点击注册
+    register() {
+      this.$Router.pushTab('/pages/login/register');
     },
+
+    //点击我已阅读
     checkboxChange(v) {
       this.isChecked = v;
     },
 
+    //点击手机号无法使用?
+    noPhone() {
+      this.$message('要跳转到解决方案哦 还没写');
+    },
+
     //点击弹框确认
     confirmShow() {
       this.isChecked = true;
       this.show = false;
       setTimeout(() => {
         this.login();
-      }, 500);
+      }, 250);
     },
 
     //关闭弹框f

+ 285 - 0
src/pages/login/register.vue

@@ -0,0 +1,285 @@
+<template>
+  <view class="container">
+    <u-image src="@/static/logo.png"></u-image>
+    <view class="login-form-wrap">
+      <u--form
+        labelPosition="left"
+        :model="loginForm"
+        :rules="rules"
+        ref="loginForm"
+      >
+        <u-form-item prop="mobile" borderBottom>
+          <u-input
+            v-model="loginForm.mobile"
+            maxlength="11"
+            border="none"
+            focus
+            placeholder="请输入手机号"
+            @focus="showKeyboard"
+          >
+            <template slot="prefix">
+              <view class="phone-prefix">
+                <text>+86</text>
+                <u-icon name="arrow-down-fill"></u-icon>
+              </view>
+            </template>
+          </u-input>
+        </u-form-item>
+        <u-form-item prop="captcha" borderBottom label="密码">
+          <u-input
+            v-model="loginForm.captcha"
+            maxlength="6"
+            border="none"
+            placeholder="请输入密码"
+          >
+          </u-input>
+        </u-form-item>
+        <u-form-item prop="captcha" borderBottom>
+          <u-input
+            v-model="loginForm.captcha"
+            maxlength="6"
+            border="none"
+            placeholder="请输入短信验证码"
+          >
+            <template slot="suffix">
+              <u-code
+                ref="uCode"
+                :seconds="seconds"
+                changeText="X秒后重新获取"
+                end-text="重新获取"
+                start-text="获取验证码"
+                @change="codeChange"
+                :keep-running="true"
+              ></u-code>
+              <u--text :text="tips" @tap="getCode" type="primary"></u--text>
+            </template>
+          </u-input>
+        </u-form-item>
+        <view class="phone-question" @click="noPhone">手机号无法使用?</view>
+        <u-form-item>
+          <u-button
+            type="primary"
+            :disabled="isDisabled"
+            :loading="loading"
+            shape="circle"
+            @click="login"
+            >注册</u-button
+          >
+        </u-form-item>
+      </u--form>
+      <view class="user-agreement">
+        <u-checkbox-group>
+          <u-checkbox
+            shape="circle"
+            @change="checkboxChange"
+            :checked="isChecked"
+          ></u-checkbox>
+        </u-checkbox-group>
+        <text class="user-agreement-text">
+          我已阅读并同意
+          <text class="terms">《用户协议》</text>
+          <text class="terms">《隐私政策》</text>
+          <text class="terms">《儿童/青少年个人信息保护规则》</text>
+        </text>
+      </view>
+    </view>
+
+    <view>
+      <u-popup :show="show" @close="close" mode="center">
+        <view
+          style="
+            height: 100rpx;
+            width: 700rpx;
+            align-items: center;
+            display: flex;
+            justify-content: center;
+          "
+        >
+          <text style="color: gray; font-size: 14px">我已阅读并同意</text>
+          <text style="font-weight: bold">《用户协议》</text>
+          <text style="font-weight: bold">《隐私政策》</text>
+        </view>
+        <u-button @click="confirmShow" type="primary" :loading="loading"
+          >确认</u-button
+        >
+      </u-popup>
+    </view>
+  </view>
+</template>
+
+<script>
+import { getSmsCodeByPhone, loginByPhoneAndSmsCode } from '@/api/login';
+
+export default {
+  data() {
+    return {
+      loginForm: {
+        client_id: 'chelvc_client',
+        client_secret: 'qWBe6jD%GCuPPTkP',
+        grant_type: 'sms',
+        token: '',
+        mobile: '18888888888',
+        captcha: '363636',
+      },
+      rules: {
+        mobile: [
+          {
+            required: true,
+            trigger: ['change', 'blur'],
+            message: '请输入您的手机号',
+          },
+          {
+            validator: (rule, value, cb) => {
+              return uni.$u.test.mobile(value);
+            },
+            message: '手机号码格式不正确',
+            trigger: ['change', 'blur'],
+          },
+        ],
+        captcha: [
+          {
+            required: true,
+            trigger: ['change', 'blur'],
+            message: '请输入六位数验证码',
+          },
+        ],
+      },
+      seconds: 120,
+      tips: '',
+      isChecked: false,
+      show: false,
+      loading: false,
+    };
+  },
+  onReady() {
+    this.$refs.loginForm.setRules(this.rules);
+  },
+  computed: {
+    isDisabled() {
+      return !(this.loginForm.mobile && this.loginForm.captcha.length === 6);
+    },
+  },
+  methods: {
+    getCode() {
+      if (!this.loginForm.mobile) return uni.$u.toast('请输入您的手机号!');
+      if (!uni.$u.test.mobile(this.loginForm.mobile))
+        return uni.$u.toast('手机号码格式不正确!');
+      // TODO: 处理验证码倒计时
+      if (this.$refs.uCode.canGetCode) {
+        getSmsCodeByPhone(this.loginForm.mobile)
+          .then(res => {
+            if (res.code === 200) {
+              uni.$u.toast('验证码已发送');
+              this.loginForm.token = res.data.token;
+              this.$refs.uCode.start();
+            }
+          })
+          .catch(err => {
+            uni.$u.toast('无法发送验证码');
+            this.$refs.uCode.start();
+          });
+      }
+    },
+
+    //点击登录
+    async login() {
+      if (!this.isChecked) {
+        this.show = true;
+        return;
+      }
+      this.loading = true;
+      loginByPhoneAndSmsCode(this.loginForm)
+        .then(res => {
+          this.loading = false;
+          if (res.access_token) {
+            uni.$u.toast('登录成功');
+            this.$store.commit('SET_ACCESS_TOKEN', res.access_token);
+            this.$store.commit('SET_REFRESH_TOKEN', res.refresh_token);
+            setTimeout(() => {
+              this.$Router.pushTab('/pages/tabbar/home/index');
+            }, 1500);
+          }
+        })
+        .catch(err => {
+          this.loading = false;
+          uni.$u.toast('登录失败-' + err.data.error_description);
+        });
+    },
+
+    //点击注册
+    register() {
+      this.$Router.pushTab('/pages/login/register');
+    },
+
+    codeChange(text) {
+      this.tips = text;
+    },
+    checkboxChange(v) {
+      this.isChecked = v;
+    },
+
+    //自动调出键盘
+    showKeyboard() {
+      return;
+      if (this.$q.platform.is.cordova) {
+        cordova.plugins.Keyboard.show();
+      }
+    },
+
+    //点击手机号无法使用?
+    noPhone() {
+      this.$message('要跳转到解决方案哦 还没写');
+    },
+
+    //点击弹框确认
+    confirmShow() {
+      this.isChecked = true;
+      this.show = false;
+      setTimeout(() => {
+        this.login();
+      }, 250);
+    },
+
+    //关闭弹框f
+    close() {
+      this.show = false;
+    },
+  },
+};
+</script>
+
+<style scoped lang="scss">
+.container {
+  padding: 0 40rpx;
+  margin: 0 auto;
+}
+.login-form-wrap {
+  margin-top: 200rpx;
+  .phone-prefix {
+    display: flex;
+    align-items: center;
+    padding-right: 20rpx;
+    border-right: 2rpx solid $uni-text-color-grey;
+    margin-right: 20rpx;
+  }
+  .phone-question {
+    text-align: right;
+    font-size: 24rpx;
+    padding: 20rpx 0 20rpx 0;
+  }
+  .user-agreement {
+    display: flex;
+    padding: 0 10rpx;
+    .user-agreement-text {
+      font-size: 24rpx;
+      color: $uni-text-color-grey;
+      margin-top: 20rpx;
+      margin-left: 20rpx;
+      .terms {
+        color: $uni-text-color;
+        font-weight: 400;
+      }
+    }
+  }
+}
+</style>

+ 12 - 20
src/pages/tabbar/community/index.vue

@@ -1,7 +1,7 @@
 <template>
   <view>
     <!-- 关注和推荐 -->
-    <u-navbar leftIcon="search" leftIconSize="32">
+    <u-navbar leftIcon="" leftIconSize="32">
       <view slot="center">
         <u-tabs :list="list" lineWidth="32" />
       </view>
@@ -11,18 +11,12 @@
       <!-- 搜索 -->
       <view
         class="search-item"
-        @click="$Router.push('/pages/community/commSearch/index')"
+        @click="$Router.push('/pages/common/search/index')"
       >
         <u-search :showAction="true" actionText="取消" />
       </view>
-      <swiper
-        class="swiper"
-        style="height: 100vh"
-        :indicator-dots="indicatorDots"
-        :autoplay="autoplay"
-        :interval="interval"
-        :duration="duration"
-      >
+
+      <swiper class="swiper" style="height: 100vh" :duration="duration">
         <swiper-item>
           <scroll-view
             scroll-y="true"
@@ -36,6 +30,7 @@
             </view>
           </scroll-view>
         </swiper-item>
+
         <swiper-item>
           <scroll-view scroll-y="true">
             <view style="padding: 10rpx 20rpx">
@@ -57,33 +52,30 @@ export default {
     return {
       list: [{ name: '关注' }, { name: '推荐' }],
       current: 0,
-      //swiper
       duration: 700,
-      // scroll
       scrollTop: 0,
       old: {
         scrollTop: 0,
       },
     };
   },
+
   computed: {
     totalHeight() {
       return uni.getSystemInfoSync().statusBarHeight + 44;
     },
   },
+
   methods: {
-    upper(e) {
-      // console.log(e);
-    },
-    lower(e) {
-      // console.log(e);
-    },
+    upper(e) {},
+
+    lower(e) {},
+
     scroll(e) {
-      // console.log(e);
       this.old.scrollTop = e.detail.scrollTop;
     },
+
     goTop(e) {
-      // 解决view层不同步的问题
       this.scrollTop = this.old.scrollTop;
       this.$nextTick(() => {
         this.scrollTop = 0;

+ 40 - 16
src/pages/tabbar/home/index.vue

@@ -1,5 +1,6 @@
 <template>
   <view class="home">
+    <!-- 顶部导航 -->
     <view class="nav-bar" v-if="opacity == 1">
       <u-navbar :bgColor="'#ffffff'">
         <view slot="left">
@@ -11,11 +12,12 @@
             placeholder="请输入搜索内容"
             :showAction="false"
             v-model="keyword"
+            @focus="$Router.push('/pages/common/search/index')"
           />
         </view>
       </u-navbar>
     </view>
-    <!-- 顶部导航 -->
+
     <view
       class="home-header"
       :style="{ paddingTop: totalHeight + 'px', opacity: 1 - opacity }"
@@ -35,15 +37,17 @@
         />
       </view>
     </view>
+
     <!-- 轮播图 -->
     <view class="home-swiper">
       <u-swiper :list="swiperList" indicator @change="change" @click="click" />
     </view>
+
     <!-- 商品分类 -->
     <view class="home-list">
       <u-grid :border="false" col="5">
         <u-grid-item
-          v-for="(item, index) in categories"
+          v-for="item in categories"
           :key="item.id"
           @tap="handleMenuClick(item)"
         >
@@ -57,6 +61,7 @@
       </u-grid>
       <u-toast ref="uToast" />
     </view>
+
     <!-- 热门推荐 -->
     <view class="hot">
       <u-cell
@@ -87,6 +92,7 @@
         ></u-empty>
       </block>
     </view>
+
     <!-- 附近商家 -->
     <view class="near">
       <u-cell
@@ -126,7 +132,6 @@ import { mapGetters } from 'vuex';
 import RecommendItem from '@/components/merchant/RecommendItem.vue';
 import HotItem from '@/components/merchant/HotItem.vue';
 import { getHomePageApi, getCategoriesApi } from '@/api/tabbar/home';
-
 export default {
   components: {
     RecommendItem,
@@ -137,6 +142,7 @@ export default {
       list: [],
       keyword: '',
       swiperList: [
+        //轮播图
         'https://cdn.uviewui.com/uview/swiper/swiper1.png',
         'https://cdn.uviewui.com/uview/swiper/swiper2.png',
         'https://cdn.uviewui.com/uview/swiper/swiper3.png',
@@ -149,20 +155,24 @@ export default {
       scrollTop: 0,
     };
   },
+
   computed: {
     ...mapGetters(['location']),
     totalHeight() {
-      return (
-        uni.getSystemInfoSync().statusBarHeight +
+      return;
+      return uni.getSystemInfoSync().statusBarHeight +
         uni.getMenuButtonBoundingClientRect().height
-      );
+        ? height
+        : '';
     },
+
     opacity() {
       if (this.scrollTop < this.totalHeight) {
         return (this.scrollTop / this.totalHeight).toFixed(2);
       }
       return 1;
     },
+
     categories() {
       let initData = this.homeData.categories.map(item => {
         if (!item.icon) {
@@ -184,10 +194,25 @@ export default {
       return result;
     },
   },
+
+  watch: {
+    location: {
+      handler: async function (newVal, oldVal) {
+        const result = await getCurrentLocation(newVal);
+        const param = Object.assign({}, { region: result.data.id }, newVal);
+        this.getHomeData(param);
+      },
+    },
+  },
+
+  //滚动页面触发
   onPageScroll(e) {
     this.scrollTop = e.scrollTop;
   },
-  onLoad() {
+
+  //页面加载
+  async onLoad() {
+    const result = await getHomePage();
     setTimeout(() => {
       this.list = new Array(10000).fill(1);
     }, 5000);
@@ -206,11 +231,16 @@ export default {
       },
     });
   },
+
   methods: {
+    //轮播图切换
     change() {},
+
+    //轮播图点击
     click(name) {
       this.$refs.uToast.success(`点击了第${name}个`);
     },
+
     // 获取首页数据
     getHomeData(location) {
       getHomePageApi(location)
@@ -223,8 +253,10 @@ export default {
           console.log(err);
         });
     },
+
     // 手动选择城市
     manualGetLocation() {
+      console.log(111);
       uni.chooseLocation({
         success: res => {
           this.$store.commit('SET_LOCATION', {
@@ -234,6 +266,7 @@ export default {
         },
       });
     },
+
     // 点击菜单
     handleMenuClick(item) {
       if (item.id === 'all') {
@@ -243,15 +276,6 @@ export default {
       }
     },
   },
-  watch: {
-    location: {
-      handler: async function (newVal, oldVal) {
-        const result = await getCurrentLocation(newVal);
-        const param = Object.assign({}, { region: result.data.id }, newVal);
-        this.getHomeData(param);
-      },
-    },
-  },
 };
 </script>
 

+ 16 - 12
src/pages/tabbar/mine/index.vue

@@ -27,8 +27,7 @@
             class="clickLogin"
             v-else
             @tap="$Router.push('/pages/login/index')"
-          >
-            点击登录
+            >点击登录/注册
           </view>
         </view>
       </view>
@@ -57,7 +56,7 @@
         class="order-out-box"
         @tap="$Router.push('/pages/user/myOrder/index')"
       > -->
-	  <view class="order-out-box">
+      <view class="order-out-box">
         <view class="order-inner-box">
           <u-grid :border="false" col="4" style="background-color: #fff">
             <u-grid-item
@@ -68,7 +67,7 @@
                 :customStyle="{ paddingTop: 20 + 'rpx' }"
                 :name="listItem.name"
                 :size="34"
-				@tap="gotoOrder(listItem)"
+                @tap="gotoOrder(listItem)"
               ></u-icon>
               <text class="grid-text">{{ listItem.title }}</text>
             </u-grid-item>
@@ -184,7 +183,7 @@ export default {
         {
           name: 'lock',
           title: '待付款',
-		  order: true
+          order: true,
         },
         {
           name: 'star',
@@ -215,26 +214,31 @@ export default {
       ],
     };
   },
+
   computed: {
     ...mapGetters(['user_info']),
   },
-  methods:{
-	  gotoOrder(item){
-		  if(item.order){
-			this.$Router.push('/pages/order/order');
-		  }
-	  }
-  }
+
+  methods: {
+    gotoOrder(item) {
+      if (item.order) {
+        this.$Router.push('/pages/order/order');
+      }
+    },
+  },
 };
 </script>
 <style lang="scss" scoped>
 .container {
+  padding-top: 5px;
   min-height: 100vh;
   background-color: #efefef;
 }
 
 /* 顶部登录 */
 .head-wrap {
+  padding-top: 5px;
+  margin-top: 5px;
   background-color: #347caf;
   height: 390rpx;