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. 2
      pages.json
  5. 4
      pages/index/components/home.vue
  6. 178
      pages/index/components/mine.vue
  7. BIN
      static/head-portrait.jpg
  8. BIN
      static/head-portrait.png
  9. BIN
      static/img/qq.png
  10. BIN
      static/img/qrcode.png
  11. BIN
      static/img/shanda1.png
  12. BIN
      static/img/shanda2.png
  13. BIN
      static/img/sinaweibo.png
  14. BIN
      static/img/weixin.png
  15. BIN
      static/logo.png
  16. 14
      store/modules/user/actions.js
  17. 21
      utils/user.js

5
App.vue

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

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

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

15
package.json

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

2
pages.json

@ -3,7 +3,7 @@
{ {
"path": "pages/index/index", "path": "pages/index/index",
"style": { "style": {
"navigationBarTitleText": "山大健康码" "navigationBarTitleText": "山大健康码"
} }
}, },
{ {

4
pages/index/components/home.vue

@ -2,7 +2,7 @@
<view class="content flex flex-direction"> <view class="content flex flex-direction">
<view v-if="healthCode" style="position: relative;"> <view v-if="healthCode" style="position: relative;">
<image <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" class="bg1"
></image> ></image>
<view class="bg-code" @click="getPreviewImg(healthCode)"> <view class="bg-code" @click="getPreviewImg(healthCode)">
@ -13,7 +13,7 @@
</view> </view>
<image <image
v-else 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" class="bg"
></image> ></image>

178
pages/index/components/mine.vue

@ -1,100 +1,100 @@
<template> <template>
<view> <view>
<!-- 头部 --> <!-- 头部 -->
<view class="cu-card flex bg-white" v-if="user && user.wxInfo"> <view class="cu-card flex bg-white" v-if="user && user.wxInfo">
<view class="flex flex-sub align-center padding-xl"> <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> <image class="xl cu-avatar" :src="user.wxInfo.headImgUrl"></image>
</view> </view>
<view class="flex-sub padding-left"> <view class="flex-sub padding-left">
<view class="text-xxl">{{ user.wxInfo.nickname }}</view> <view class="text-xxl">{{ user.wxInfo.nickname }}</view>
<!-- <view class="text-df padding-top-xs">{{ user.wxInfo.classes }}</view> --> <!-- <view class="text-df padding-top-xs">{{ user.wxInfo.classes }}</view> -->
</view> </view>
<image class="healthy-code" :src="healthCode" @tap="getPreviewImg(healthCode)"></image>
</view>
</view>
<view class="cu-card flex bg-white" v-else>
<view class="flex flex-sub align-center padding-xl">
<view class="round xl cu-avatar portrait">
<image class="xl cu-avatar" :src="userInfo.avatarUrl"></image>
</view>
<view class="flex-sub padding-left">
<view class="text-xxl">{{ userInfo.nickName }}</view>
<!-- <view class="text-df padding-top-sm">{{ userInfo.classes }}</view> -->
</view>
</view>
</view>
<!-- 列表 -->
<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')">
<text class="text-xl">个人信息</text>
<view class="iconfont icon-right more"></view>
</view>
<view class="cu-item" hover-class="cc-active" @tap="openPage('/pages/my-code/my-code')">
<text class="text-xl">我的健康打卡</text>
<view class="iconfont icon-right more"></view>
</view>
<view class="cu-item" hover-class="cc-active" @tap="openPage('/pages/my-trips/my-trips')">
<text class="text-xl">我的行程</text>
<view class="iconfont icon-right more"></view>
</view>
<view class="cu-item" hover-class="cc-active" @tap="openPage('/pages/my-signs/my-signs')">
<text class="text-xl">我的校园打卡</text>
<view class="iconfont icon-right more"></view>
</view>
</view>
</view>
</view>
<image class="healthy-code" :src="healthCode" @tap="getPreviewImg(healthCode)"></image>
</view>
</view>
<view class="cu-card flex bg-white" v-else>
<view class="flex flex-sub align-center padding-xl">
<view class="round xl cu-avatar portrait">
<image class="xl cu-avatar" :src="userInfo.avatarUrl"></image>
</view>
<view class="flex-sub padding-left">
<view class="text-xxl">{{ userInfo.nickName }}</view>
<!-- <view class="text-df padding-top-sm">{{ userInfo.classes }}</view> -->
</view>
</view>
</view>
<!-- 列表 -->
<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')"
>
<text class="text-xl">个人信息</text>
<view class="iconfont icon-right more"></view>
</view>
<view class="cu-item" hover-class="cc-active" @tap="openPage('/pages/my-code/my-code')">
<text class="text-xl">我的健康打卡</text>
<view class="iconfont icon-right more"></view>
</view>
<view class="cu-item" hover-class="cc-active" @tap="openPage('/pages/my-trips/my-trips')">
<text class="text-xl">我的行程</text>
<view class="iconfont icon-right more"></view>
</view>
<view class="cu-item" hover-class="cc-active" @tap="openPage('/pages/my-signs/my-signs')">
<text class="text-xl">我的校园打卡</text>
<view class="iconfont icon-right more"></view>
</view>
</view>
</view>
</view>
</template> </template>
<script> <script>
import { import { mapState } from 'vuex';
mapState export default {
} from 'vuex'; name: 'Mine',
export default { data() {
name: 'Mine', return {
data() { userInfo: {
return { avatarUrl: '/static/head-portrait.png',
userInfo: { nickName: '健康码',
avatarUrl: '../../../static/head-portrait.jpg', // classes: '19',
nickName: '健康码', },
// classes: '19', };
}, },
};
}, computed: mapState('user', ['healthCode', 'user']),
computed: mapState('user', ['healthCode', 'user']), methods: {
//
methods: { getPreviewImg(image) {
// var imgArr = [];
getPreviewImg(image) { imgArr.push(image);
var imgArr = []; uni.previewImage({
imgArr.push(image); urls: imgArr,
uni.previewImage({ current: imgArr[0],
urls: imgArr, });
current: imgArr[0] },
}); },
}, };
}
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.portrait { .portrait {
overflow: hidden; overflow: hidden;
} }
.healthy-code { .healthy-code {
width: 70rpx; width: 70rpx;
height: 70rpx; height: 70rpx;
} }
.more { .more {
font-size: 18px; font-size: 18px;
color: $grey; color: $grey;
} }
</style> </style>

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

21
utils/user.js

@ -101,7 +101,6 @@ export const wxWorkLogin = () => {
export const mpLogin = () => { export const mpLogin = () => {
try { try {
const res = uni.getSystemInfoSync(); const res = uni.getSystemInfoSync();
console.log('res.environment: ', res.environment);
if (res.environment === 'wxwork') { if (res.environment === 'wxwork') {
return wxWorkLogin(); return wxWorkLogin();
} else { } else {
@ -111,3 +110,23 @@ export const mpLogin = () => {
console.log('err: ', err); 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