diff --git a/.eslintrc.js b/.eslintrc.js index 067c1dd..d1d7b97 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -41,8 +41,8 @@ module.exports = { Vue: true, VueRouter: true, Vuex: true, - axios: true, _: true, uni: true, + wx: true, }, }; diff --git a/CHANGELOG.md b/CHANGELOG.md index c170a6f..c716016 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,4 @@ -# 0.1.0 (2021-08-31) +# 0.1.0 (2021-09-09) ### 🌟 新功能 范围|描述|commitId @@ -23,6 +23,7 @@ - | 上传逻辑变化 | 3ff1dc2 - | 任务状态时间显示 | 56f5183 - | 任务进行中状态数字 | 27b7326 + - | 修改小程序id | 4206bf2 - | 全局插件及默认插件位置修改 | 6c80d08 - | 升级版本v3.1.0;tailwindcss添加class | 9ef05e1 - | 向右箭头图标变化 | 8e9ca55 @@ -54,6 +55,7 @@ - | 细节调整,添加project-webview | 4d9050b - | 绑定手机号 | 52e0352 - | 缓存修改 | 63e1f0d + - | 获取用户收取那,提交用户信息 | a3c54f1 - | 角色栏实现 | 94cd671 - | 设置小红点 | 9316bcb - | 距调整pc端 | 5069aa1 @@ -193,6 +195,7 @@ - | 修改代码格式 | 14123d7 - | 修改定期任务骨架屏高度 | 909a734 - | 小红点api缓存修改 | e992343 + - | 提交本地代码 | e0cf2ed - | 插件查询及展示 | 4dba770 - | 整理代码 | 7a55315 - | 日历的更改 | 7353ac8 @@ -220,6 +223,7 @@ 信息配置 | 配置eslint等配置 | 7421443 - | 修复不能build的问题 | 0b7b91e - | 删除多余的构建的命令 | 3f4eb2f + - | 添加mp-weixin的构建命令 | 3776a67 范围|描述|commitId diff --git a/package.json b/package.json index aed2d09..df1af49 100644 --- a/package.json +++ b/package.json @@ -12,8 +12,8 @@ "dev:h5-pro": "cross-env NODE_ENV=development UNI_PLATFORM=h5 vue-cli-service uni-serve --mode production", "build:h5-test": "cross-env NODE_ENV=production UNI_PLATFORM=h5 vue-cli-service uni-build --mode development", "build:h5": "cross-env NODE_ENV=production UNI_PLATFORM=h5 vue-cli-service uni-build --mode production", - "build:app-plus": "cross-env NODE_ENV=production UNI_PLATFORM=app-plus vue-cli-service uni-build", - "build:mp-weixin": "cross-env NODE_ENV=production UNI_PLATFORM=mp-weixin vue-cli-service uni-build", + "build:app-plus": "cross-env NODE_ENV=production UNI_PLATFORM=app-plus vue-cli-service uni-build --mode production", + "build:mp-weixin": "cross-env NODE_ENV=production UNI_PLATFORM=mp-weixin vue-cli-service uni-build --mode production", "cz": "npm run log && git add . && git cz", "dev:app-plus": "cross-env NODE_ENV=development UNI_PLATFORM=app-plus vue-cli-service uni-build --watch", "dev:custom": "cross-env NODE_ENV=development uniapp-cli custom", diff --git a/src/App.vue b/src/App.vue index 8bcef53..ce88e44 100644 --- a/src/App.vue +++ b/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); + }, + }); + }, }, }; diff --git a/src/apis/tall.js b/src/apis/tall.js index 04cedce..37285b3 100644 --- a/src/apis/tall.js +++ b/src/apis/tall.js @@ -30,6 +30,8 @@ const install = (Vue, vm) => { vm.$u.api.getToken = userId => vm.$u.get(`${tall}/users/userId`, { userId }); // 绑定手机号 vm.$u.api.phoneBind = (phone, smsCode) => vm.$u.http.post(`${tall}/users/binding`, { phone, smsCode }); + // 修改用户信息 + vm.$u.api.updateUserInfo = params => vm.$u.http.post(`${tall}/users/userInfo`, params); // 获取项目列表 vm.$u.api.getProjects = (startTime, endTime) => vm.$u.post(`${tall}/project/query`, { startTime, endTime }); diff --git a/src/components/Upload/Upload.vue b/src/components/Upload/Upload.vue index 75f7cfd..f23e6e9 100644 --- a/src/components/Upload/Upload.vue +++ b/src/components/Upload/Upload.vue @@ -27,6 +27,7 @@ export default { }); }, 2000); } catch (error) { + console.log('error: ', error); this.$emit('error', error); } }, diff --git a/src/config/user.js b/src/config/user.js index a27a905..d6aa986 100644 --- a/src/config/user.js +++ b/src/config/user.js @@ -22,7 +22,7 @@ export const mp = () => { const params = { client: uni.$t.user.clients['mp'], type: uni.$t.user.types['mp'], - data: { identifier: res.code }, + data: { identifier: res.code, credential: 'tall' }, }; resolve(params); } else { diff --git a/src/manifest.json b/src/manifest.json index 0b7f1bc..7464ba9 100644 --- a/src/manifest.json +++ b/src/manifest.json @@ -1,6 +1,6 @@ { "name": "TALL", - "appid": "wx356e01c7eb01d55d", + "appid": "wxf72a76c2ea24a472", "description": "", "versionName": "1.0.0", "versionCode": "100", @@ -57,7 +57,7 @@ /* 快应用特有相关 */ }, "mp-weixin": { - "appid": "wx356e01c7eb01d55d", + "appid": "wxf72a76c2ea24a472", "setting": { "urlCheck": false }, diff --git a/src/mixins/userAuth.js b/src/mixins/userAuth.js new file mode 100644 index 0000000..ffbe93f --- /dev/null +++ b/src/mixins/userAuth.js @@ -0,0 +1,48 @@ +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; // 用户信息里有微信信息就不用再获取了 + if (this.token) { + this.updateUserInfo(); + } else { + waitTokenRequest(this.updateUserInfo); + } + }, + + // 弹出授权框 + // 用户允许后 提交微信用户信息 + updateUserInfo() { + /* #ifdef MP-WEIXIN */ + uni.getUserProfile({ + desc: 'TALL仅需要获取您的基本用户信息', + success: async res => { + const { avatarUrl, city, country, gender, language, nickName, province } = res.userInfo; + const data = await this.$u.api.updateUserInfo({ + city, + country, + headImgUrl: avatarUrl, + language, + nickname: nickName, + province, + sex: gender, + }); + console.log('data: ', data); + const { user } = this; + user.wxInfo = data; + this.setUser(user); + }, + fail: error => { + console.log('error: ', error); + }, + }); + /* #endif */ + }, + }, +}; diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue index 7b91407..fad3cf0 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -1,10 +1,12 @@