Browse Source

perf: 提交本地代码

tall
wally 4 years ago
parent
commit
e0cf2ed7e2
  1. 3
      CHANGELOG.md
  2. 20
      src/App.vue
  3. 1
      src/components/Upload/Upload.vue
  4. 12
      src/mixins/userAuth.js
  5. 2
      src/pages/index/index.vue
  6. 2
      src/pages/phone-bind/phone-bind.vue
  7. 15
      src/store/index.js

3
CHANGELOG.md

@ -1,4 +1,4 @@
# 0.1.0 (2021-09-02)
# 0.1.0 (2021-09-09)
### 🌟 新功能
范围|描述|commitId
@ -55,6 +55,7 @@
- | 细节调整,添加project-webview | 4d9050b
- | 绑定手机号 | 52e0352
- | 缓存修改 | 63e1f0d
- | 获取用户收取那,提交用户信息 | a3c54f1
- | 角色栏实现 | 94cd671
- | 设置小红点 | 9316bcb
- | 距调整pc端 | 5069aa1

20
src/App.vue

@ -5,9 +5,10 @@ export default {
async onLaunch(options) {
console.log('options: ', options);
this.checkNetwork(); //
this.getSystemInfo(); //
/* #ifdef MP-WEIXIN */
await this.signin();
this.initSocket();
/* #endif */
/* #ifdef H5 */
@ -23,9 +24,8 @@ export default {
this.noPhone(data.phone);
}
}
// FIXME:
this.initSocket();
/* #endif */
this.initSocket();
},
computed: {
@ -36,7 +36,7 @@ export default {
methods: {
...mapActions('user', ['getToken']),
...mapActions('socket', ['initSocket']),
...mapMutations(['setNetworkConnected']),
...mapMutations(['setNetworkConnected', 'setSystemInfo']),
...mapMutations('user', ['setToken', 'setUser']),
// store
@ -79,6 +79,18 @@ export default {
this.$u.route('/pages/phone-bind/phone-bind');
}
},
//
getSystemInfo() {
uni.getSystemInfo({
success: result => {
this.setSystemInfo(result);
},
fail: error => {
console.error('getSystemInfo fail:', error);
},
});
},
},
};
</script>

1
src/components/Upload/Upload.vue

@ -27,6 +27,7 @@ export default {
});
}, 2000);
} catch (error) {
console.log('error: ', error);
this.$emit('error', error);
}
},

12
src/mixins/userAuth.js

@ -1,9 +1,11 @@
import { mapState } from 'vuex';
import { mapMutations, mapState } from 'vuex';
import { waitTokenRequest } from '@/utils/cacheAndRequest';
export default {
computed: mapState('user', ['token', 'user']),
methods: {
...mapMutations('user', ['setUser']),
// 获取授权
openAuth() {
if (this.user && this.user.wxInfo && this.user.wxInfo.nickname) return; // 用户信息里有微信信息就不用再获取了
@ -20,9 +22,9 @@ export default {
/* #ifdef MP-WEIXIN */
uni.getUserProfile({
desc: 'TALL仅需要获取您的基本用户信息',
success: res => {
success: async res => {
const { avatarUrl, city, country, gender, language, nickName, province } = res.userInfo;
this.$u.api.updateUserInfo({
const data = await this.$u.api.updateUserInfo({
city,
country,
headImgUrl: avatarUrl,
@ -31,6 +33,10 @@ export default {
province,
sex: gender,
});
console.log('data: ', data);
const { user } = this;
user.wxInfo = data;
this.setUser(user);
},
fail: error => {
console.log('error: ', error);

2
src/pages/index/index.vue

@ -3,8 +3,10 @@
<view class="relative" @touchmove="onMove">
<!-- 日历 -->
<Calendar @selected-change="onDateChange" :show-back="true" ref="calendar" @handleFindPoint="handleFindPoint" />
<!-- #ifdef H5 -->
<!-- 上传 导入wbs -->
<Upload @success="onUploadSuccess" @error="onUploadError" />
<!-- #endif -->
</view>
<!-- 项目列表 -->

2
src/pages/phone-bind/phone-bind.vue

@ -27,7 +27,7 @@
</template>
<script>
import UserAuthMixin from '@/utils/userAuth';
import UserAuthMixin from '@/mixins/userAuth';
export default {
mixins: [UserAuthMixin],

15
src/store/index.js

@ -9,6 +9,7 @@ import user from './user/index';
const state = {
networkConnected: true, // 网络是否连接
forceUseStorage: false, // 强制启用storage
systemInfo: null, // 系统设备信息
};
const getters = {
@ -17,6 +18,11 @@ const getters = {
useStorage({ networkConnected, forceUseStorage }) {
return forceUseStorage || !networkConnected;
},
// 是不是微信平台
isWeChat({ systemInfo }) {
return !(!systemInfo || !systemInfo.host || systemInfo.host.env !== 'WeChat');
},
};
const mutations = {
@ -28,6 +34,15 @@ const mutations = {
setNetworkConnected(state, networkConnected) {
state.networkConnected = networkConnected;
},
/**
* 设置系统信息的数据
* @param {object} state
* @param {object | null} data 获取到的数据
*/
setSystemInfo(state, data) {
state.systemInfo = data;
},
};
Vue.use(Vuex);

Loading…
Cancel
Save