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 范围|描述|commitId
@ -55,6 +55,7 @@
- | 细节调整,添加project-webview | 4d9050b - | 细节调整,添加project-webview | 4d9050b
- | 绑定手机号 | 52e0352 - | 绑定手机号 | 52e0352
- | 缓存修改 | 63e1f0d - | 缓存修改 | 63e1f0d
- | 获取用户收取那,提交用户信息 | a3c54f1
- | 角色栏实现 | 94cd671 - | 角色栏实现 | 94cd671
- | 设置小红点 | 9316bcb - | 设置小红点 | 9316bcb
- | 距调整pc端 | 5069aa1 - | 距调整pc端 | 5069aa1

20
src/App.vue

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

1
src/components/Upload/Upload.vue

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

2
src/pages/index/index.vue

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

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

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

15
src/store/index.js

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

Loading…
Cancel
Save