Browse Source

dd init

remotes/origin/HEAD
wally 5 years ago
parent
commit
ae008f02df
  1. 5
      App.vue
  2. 2
      components/nav-bottom/nav-bottom.vue
  3. 15
      package.json
  4. 4
      pages/index/components/home.vue
  5. 20
      pages/index/components/mine.vue
  6. BIN
      static/head-portrait.jpg
  7. BIN
      static/head-portrait.png
  8. BIN
      static/img/qq.png
  9. BIN
      static/img/qrcode.png
  10. BIN
      static/img/shanda1.png
  11. BIN
      static/img/shanda2.png
  12. BIN
      static/img/sinaweibo.png
  13. BIN
      static/img/weixin.png
  14. BIN
      static/logo.png
  15. 14
      store/modules/user/actions.js
  16. 21
      utils/user.js

5
App.vue

@ -7,6 +7,7 @@ import { formatQuery } from 'utils/util';
export default {
async onLaunch(options) {
console.log('options: ', options);
// #ifdef MP-WEIXIN
uni.getSetting({
success(res) {
if (!res.authSetting['scope.userLocation']) {
@ -17,9 +18,10 @@ export default {
}
},
});
// #endif
try {
if (options.query.scene) {
if (options.query && options.query.scene) {
const query = formatQuery(decodeURIComponent(options.query.scene));
if (options.path === 'pages/index/index' && query && query.d) {
await this.getTokenByUserId({ params: { userId: query.d } });
@ -42,6 +44,7 @@ export default {
methods: {
...mapActions('user', ['login', 'getUserInfo', 'getHealthTypeStatus', 'getTokenByUserId']),
async initCommon() {
const startTime = +this.$moment()
.startOf('year')

2
components/nav-bottom/nav-bottom.vue

@ -1,5 +1,5 @@
<template>
<view class="cu-bar tabbar bg-white">
<view class="cu-bar tabbar bg-white" style="width: 750rpx">
<view
:class="[index === 0 ? 'text-blue': 'text-gray']"
@tap="handleClickButton(0)"

15
package.json

@ -6,11 +6,24 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"uni-app": {
"scripts": {
"mp-dingtalk": {
"title": "钉钉小程序",
"env": {
"UNI_PLATFORM": "mp-alipay"
},
"define": {
"MP-DINGTALK": true
}
}
}
},
"repository": {
"type": "git",
"url": "https://gitee.com/ccsens_s/healthyCode.git"
},
"author": "",
"author": "wally",
"license": "ISC",
"dependencies": {
"moment": "^2.24.0"

4
pages/index/components/home.vue

@ -2,7 +2,7 @@
<view class="content flex flex-direction">
<view v-if="healthCode" style="position: relative;">
<image
src="http://m.qpic.cn/psc?/V11kyB1O080aC1/cnQ2D7YjAZ5R6pY0fmc9joZ6fC6TxFlt9mW4UhUn2PEgUne7OUt4q4mNE.k9gU.rSr8Eu*pFToZoVwUOEGDrKMycDqdn1mLFGE1dxYTGUcE!/b&bo=7gKRAu4CkQIDWXw!&rf=viewer_4&t=5"
src="/static/img/shanda2.png"
class="bg1"
></image>
<view class="bg-code" @click="getPreviewImg(healthCode)">
@ -13,7 +13,7 @@
</view>
<image
v-else
src="http://m.qpic.cn/psc?/V11kyB1O080aC1/cnQ2D7YjAZ5R6pY0fmc9jhx9v1rh8VuBAojvYxrYvg*uVMAXaD2En3CPiaHx7AWMjFTafVrGxwJR4jZd5s4ProhQT1ceDVquyQR7HVquBKk!/b&bo=7gLuAe4C7gEDORw!&rf=viewer_4&t=5"
src="/static/img/shanda1.png"
class="bg"
></image>

20
pages/index/components/mine.vue

@ -3,7 +3,7 @@
<!-- 头部 -->
<view class="cu-card flex bg-white" v-if="user && user.wxInfo">
<view class="flex flex-sub align-center padding-xl">
<view class="round xl cu-avatar portrait">
<view class="round xl cu-avatar portrait bg-white">
<image class="xl cu-avatar" :src="user.wxInfo.headImgUrl"></image>
</view>
<view class="flex-sub padding-left">
@ -28,7 +28,11 @@
<!-- 列表 -->
<view class="bg-white margin-top">
<view class="cu-list menu margin-lr">
<view class="cu-item" hover-class="cc-active" @tap="openPage('/pages/basic-info/basic-info')">
<view
class="cu-item"
hover-class="cc-active"
@tap="openPage('/pages/basic-info/basic-info')"
>
<text class="text-xl">个人信息</text>
<view class="iconfont icon-right more"></view>
</view>
@ -47,19 +51,16 @@
</view>
</view>
</view>
</template>
<script>
import {
mapState
} from 'vuex';
import { mapState } from 'vuex';
export default {
name: 'Mine',
data() {
return {
userInfo: {
avatarUrl: '../../../static/head-portrait.jpg',
avatarUrl: '/static/head-portrait.png',
nickName: '健康码',
// classes: '19',
},
@ -75,11 +76,10 @@
imgArr.push(image);
uni.previewImage({
urls: imgArr,
current: imgArr[0]
current: imgArr[0],
});
},
}
},
};
</script>

BIN
static/head-portrait.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 154 KiB

BIN
static/head-portrait.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

BIN
static/img/qq.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 61 KiB

BIN
static/img/qrcode.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

BIN
static/img/shanda1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 KiB

BIN
static/img/shanda2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 207 KiB

BIN
static/img/sinaweibo.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

BIN
static/img/weixin.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

BIN
static/logo.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

14
store/modules/user/actions.js

@ -1,5 +1,5 @@
import { showLoading, hideLoading, showModal, showToast } from 'utils/ui';
import { mpLogin, signIn } from 'utils/user';
import { mpLogin, signIn, ddLogin } from 'utils/user';
import { UPDATE_USER, USER_ID_EXCHANGE_TOKEN } from 'api/user';
import { GET_USER_INFO, HEALTH_TYPE_STATUS } from 'api/api';
import { http } from 'plugins/request/index';
@ -7,10 +7,15 @@ import { http } from 'plugins/request/index';
const actions = {
// 登录
login({ commit }) {
return new Promise((resolve, reject) => {
return new Promise(async (resolve, reject) => {
let params = null;
// #ifdef MP-WEIXIN
mpLogin()
.then(params => signIn(params))
params = await mpLogin();
// #endif
// #ifdef MP-DINGTALK
params = await ddLogin();
// #endif
signIn(params)
.then(data => {
console.log('login data: ', data);
commit('setToken', data.token);
@ -23,7 +28,6 @@ const actions = {
showModal(err.msg || '登录失败');
reject(err);
});
// #endif
});
},

21
utils/user.js

@ -101,7 +101,6 @@ export const wxWorkLogin = () => {
export const mpLogin = () => {
try {
const res = uni.getSystemInfoSync();
console.log('res.environment: ', res.environment);
if (res.environment === 'wxwork') {
return wxWorkLogin();
} else {
@ -111,3 +110,23 @@ export const mpLogin = () => {
console.log('err: ', err);
}
};
// 钉钉登录
export const ddLogin = () => {
console.log('dingtalk login.........');
try {
dd.getAuthCode({
success(res) {
console.log('res: ', res);
/*{
authCode: 'hYLK98jkf0m' // string authCode
}*/
},
fail: function(err) {
console.log('err: ', err);
},
});
} catch (error) {
console.log('error: ', error);
}
};

Loading…
Cancel
Save