Browse Source

feat(market): 添加市场模块并优化登录逻辑

- 在 market目录下添加新的页面组件- 修改 student/login 页面的登录逻辑,根据用户类型跳转到不同页面
- 更新 config.js,启用线上 API 地址
- 在 market/index 页面添加自定义导航栏
- 调整 pages.json 中的导航样式配置
master
liutong 1 year ago
parent
commit
9242d60b3a
  1. 8
      common/config.js
  2. 2
      pages.json
  3. 24
      pages/market/index/index.vue
  4. 35
      pages/student/login/login.vue

8
common/config.js

@ -1,10 +1,10 @@
// 线上地址 // 线上地址
// const Api_url='http://146.56.228.75:20021/api' const Api_url='http://146.56.228.75:20021/api'
// const img_domian = 'http://146.56.228.75:20021/' const img_domian = 'http://146.56.228.75:20021/'
//本地测试地址 //本地测试地址
const Api_url='http://zhjw.cc/api' // const Api_url='http://zhjw.cc/api'
const img_domian = 'http://zhjw.cc/' // const img_domian = 'http://zhjw.cc/'
const IsDemo = false const IsDemo = false

2
pages.json

@ -359,7 +359,7 @@
"path": "pages/market/index/index", "path": "pages/market/index/index",
"style": { "style": {
"navigationBarTitleText": "首页", "navigationBarTitleText": "首页",
"navigationStyle": "default", "navigationStyle": "custom",
"navigationBarBackgroundColor": "#fff", "navigationBarBackgroundColor": "#fff",
"navigationBarTextStyle": "black" "navigationBarTextStyle": "black"
} }

24
pages/market/index/index.vue

@ -1,5 +1,11 @@
<template> <template>
<view class="assemble"> <view class="assemble">
<!--自定义导航栏-->
<view class="navbar_section">
<view class="title">我的</view>
</view>
<view style="height: 20rpx;"></view> <view style="height: 20rpx;"></view>
<view class="div-style"> <view class="div-style">
<view style="height: 38vh;"> <view style="height: 38vh;">
@ -166,7 +172,23 @@
} }
</script> </script>
<style> <style lang="less" scoped>
//
.navbar_section{
border: 1px solid #fff;
display: flex;
justify-content: center;
align-items: center;
background: #fff;
.title{
padding: 20rpx 0;
font-size: 30rpx;
color: #858585;
}
}
.assemble { .assemble {
width: 100%; width: 100%;
height: 100vh; height: 100vh;

35
pages/student/login/login.vue

@ -47,8 +47,8 @@ import medicationApi from '@/api/medication.js';
} }
}, },
onLoad() { onLoad() {
uni.hideHomeButton() // uni.hideHomeButton()
console.log(uni.getStorageSync('um_id')) // console.log(uni.getStorageSync('um_id'))
}, },
methods: { methods: {
input(e) { input(e) {
@ -62,15 +62,40 @@ import medicationApi from '@/api/medication.js';
url: '/pages/student/login/forgot' url: '/pages/student/login/forgot'
}) })
}, },
//
login() { login() {
let item = {}; let item = {};
item['username'] = this.user item['username'] = this.user
item['password'] = this.password1 item['password'] = this.password1
//
medicationApi.login(item).then(res => { medicationApi.login(item).then(res => {
if (res.status == 200) { if (res.code == 1) {
res.data.userType = 2
uni.setStorageSync('token', res.data.token); uni.setStorageSync('token', res.data.token);
uni.switchTab({ uni.setStorageSync('userType', res.data.userType);
url: '/pages/my/my'
let url_path = ''
switch (String(res.data.userType)) {
case '1'://
url_path = '/pages/coach/home/index'
break;
case '2'://
url_path = '/pages/market/index/index'
break;
case '3'://
url_path = '/pages/student/index/index'
break;
default:
uni.showToast({
title: '用户类型错误',
icon: 'none'
})
return;
}
uni.navigateTo({
url: url_path
}) })
} else { } else {
uni.showToast({ uni.showToast({

Loading…
Cancel
Save