Showing
1 changed file
with
142 additions
and
37 deletions
| ... | @@ -4,15 +4,15 @@ | ... | @@ -4,15 +4,15 @@ |
| 4 | <div class="info"> | 4 | <div class="info"> |
| 5 | <van-row> | 5 | <van-row> |
| 6 | <van-col> | 6 | <van-col> |
| 7 | - <van-image round width="50" height="50" src="https://cdn.jsdelivr.net/npm/@vant/assets/cat.jpeg" | 7 | + <van-image round width="50" height="50" :src="userInfo.avatar" |
| 8 | style="padding-right: 1rem;" /> | 8 | style="padding-right: 1rem;" /> |
| 9 | </van-col> | 9 | </van-col> |
| 10 | <van-col class="text-wrapper" span="18"> | 10 | <van-col class="text-wrapper" span="18"> |
| 11 | <div> | 11 | <div> |
| 12 | - <div class="username">瑟日古娜</div> | 12 | + <div class="username">{{ userInfo.name }}</div> |
| 13 | <div class="toggle-user" @click="toggleUser">切换儿童</div> | 13 | <div class="toggle-user" @click="toggleUser">切换儿童</div> |
| 14 | </div> | 14 | </div> |
| 15 | - <div class="address">呼和浩特市新城区蒙古族幼儿园</div> | 15 | + <div class="address">{{ userInfo.kg_name }}</div> |
| 16 | </van-col> | 16 | </van-col> |
| 17 | </van-row> | 17 | </van-row> |
| 18 | </div> | 18 | </div> |
| ... | @@ -21,22 +21,22 @@ | ... | @@ -21,22 +21,22 @@ |
| 21 | <van-row> | 21 | <van-row> |
| 22 | <van-col span="5" offset="1" class="un-tap-color"> | 22 | <van-col span="5" offset="1" class="un-tap-color"> |
| 23 | <p>获赞</p> | 23 | <p>获赞</p> |
| 24 | - <p>25478</p> | 24 | + <p>{{ userInfo.perf_like_num }}</p> |
| 25 | </van-col> | 25 | </van-col> |
| 26 | <van-col span="1" class="divide">|</van-col> | 26 | <van-col span="1" class="divide">|</van-col> |
| 27 | <van-col span="5" class="un-tap-color"> | 27 | <van-col span="5" class="un-tap-color"> |
| 28 | <p>粉丝</p> | 28 | <p>粉丝</p> |
| 29 | - <p>45</p> | 29 | + <p>{{ userInfo.fans_num }}</p> |
| 30 | </van-col> | 30 | </van-col> |
| 31 | <van-col span="1" class="divide">|</van-col> | 31 | <van-col span="1" class="divide">|</van-col> |
| 32 | <van-col span="5" @click="getFollow"> | 32 | <van-col span="5" @click="getFollow"> |
| 33 | <p class="tap-color">关注</p> | 33 | <p class="tap-color">关注</p> |
| 34 | - <p>26</p> | 34 | + <p>{{ userInfo.follow_num }}</p> |
| 35 | </van-col> | 35 | </van-col> |
| 36 | <van-col span="1" class="divide">|</van-col> | 36 | <van-col span="1" class="divide">|</van-col> |
| 37 | <van-col span="5" @click="getUnwatch"> | 37 | <van-col span="5" @click="getUnwatch"> |
| 38 | <p class="tap-color">未看</p> | 38 | <p class="tap-color">未看</p> |
| 39 | - <p><van-tag round color="red">28</van-tag></p> | 39 | + <p><van-tag round color="red">{{ userInfo.unplay_num }}</van-tag></p> |
| 40 | </van-col> | 40 | </van-col> |
| 41 | </van-row> | 41 | </van-row> |
| 42 | </div> | 42 | </div> |
| ... | @@ -44,7 +44,8 @@ | ... | @@ -44,7 +44,8 @@ |
| 44 | 44 | ||
| 45 | <div class="van-hairline--bottom sub-handle"> | 45 | <div class="van-hairline--bottom sub-handle"> |
| 46 | <div> | 46 | <div> |
| 47 | - <my-button type="custom" :custom-style="styleObject1" @on-click="goTo('/me/verifyUser')">实名认证</my-button> | 47 | + <my-button v-if="userInfo.status === 'apply'" type="custom" :custom-style="styleObject1" @on-click="goTo('/me/verifyUser')">实名认证</my-button> |
| 48 | + <my-button v-else type="custom" :custom-style="styleObject3">已认证</my-button> | ||
| 48 | </div> | 49 | </div> |
| 49 | <div> | 50 | <div> |
| 50 | <my-button type="custom" :custom-style="styleObject2" @on-click="goTo('/me/addUser')">新增儿童</my-button> | 51 | <my-button type="custom" :custom-style="styleObject2" @on-click="goTo('/me/addUser')">新增儿童</my-button> |
| ... | @@ -63,6 +64,8 @@ | ... | @@ -63,6 +64,8 @@ |
| 63 | </div> | 64 | </div> |
| 64 | </template> | 65 | </template> |
| 65 | </div> | 66 | </div> |
| 67 | + | ||
| 68 | + <van-action-sheet v-model:show="show" :actions="actions" @select="onSelect" /> | ||
| 66 | </template> | 69 | </template> |
| 67 | 70 | ||
| 68 | <script setup> | 71 | <script setup> |
| ... | @@ -72,73 +75,178 @@ import { ref, reactive, onMounted } from 'vue' | ... | @@ -72,73 +75,178 @@ import { ref, reactive, onMounted } from 'vue' |
| 72 | import { useRoute, useRouter } from 'vue-router' | 75 | import { useRoute, useRouter } from 'vue-router' |
| 73 | import axios from '@/utils/axios'; | 76 | import axios from '@/utils/axios'; |
| 74 | import $ from 'jquery' | 77 | import $ from 'jquery' |
| 78 | +import _ from 'lodash' | ||
| 75 | import { Toast } from 'vant'; | 79 | import { Toast } from 'vant'; |
| 76 | const $route = useRoute(); | 80 | const $route = useRoute(); |
| 77 | const $router = useRouter(); | 81 | const $router = useRouter(); |
| 78 | 82 | ||
| 79 | -// 切换用户功能 | 83 | + |
| 84 | +/********** 切换用户功能 START *************/ | ||
| 85 | + | ||
| 86 | +const show = ref(false); | ||
| 87 | +let actions = ref([]); | ||
| 88 | +axios.get('/srv/?a=my_performer') | ||
| 89 | +.then(res => { | ||
| 90 | + if (res.data.code === 1) { | ||
| 91 | + actions.value = res.data.data; | ||
| 92 | + } else { | ||
| 93 | + console.warn(res); | ||
| 94 | + Toast({ | ||
| 95 | + icon: 'close', | ||
| 96 | + message: res.data.msg | ||
| 97 | + }); | ||
| 98 | + } | ||
| 99 | +}) | ||
| 100 | +.catch(err => { | ||
| 101 | + console.error(err); | ||
| 102 | +}) | ||
| 103 | + | ||
| 80 | const toggleUser = () => { | 104 | const toggleUser = () => { |
| 81 | - console.warn('切换儿童'); | 105 | + show.value = true; |
| 82 | } | 106 | } |
| 83 | -// 跳转相关页面 | 107 | + |
| 84 | -const goTo = (path) => { | 108 | +const onSelect = (item) => { |
| 85 | - $router.push({ | 109 | + // 默认情况下点击选项时不会自动收起 |
| 86 | - path: path | 110 | + // 可以通过 close-on-click-action 属性开启自动收起 |
| 111 | + show.value = false; | ||
| 112 | + // 切换当前角色 | ||
| 113 | + axios.post('/srv/?a=change_performer', { | ||
| 114 | + perf_id: item.id | ||
| 87 | }) | 115 | }) |
| 88 | -} | 116 | + .then(res => { |
| 117 | + if (res.data.code === 1) { | ||
| 118 | + // 重新获取新角色的信息 | ||
| 119 | + axios.get('/srv/?a=my_info') | ||
| 120 | + .then(res => { | ||
| 121 | + if (res.data.code === 1) { | ||
| 122 | + userInfo.value = res.data.data; | ||
| 123 | + _.each(itemList, item => { | ||
| 124 | + item.sum = userInfo.value[item.key] | ||
| 125 | + }); | ||
| 126 | + } else { | ||
| 127 | + console.warn(res); | ||
| 128 | + Toast({ | ||
| 129 | + icon: 'close', | ||
| 130 | + message: res.data.msg | ||
| 131 | + }); | ||
| 132 | + } | ||
| 133 | + }) | ||
| 134 | + .catch(err => { | ||
| 135 | + console.error(err); | ||
| 136 | + }) | ||
| 137 | + } else { | ||
| 138 | + console.warn(res); | ||
| 139 | + Toast({ | ||
| 140 | + icon: 'close', | ||
| 141 | + message: res.data.msg | ||
| 142 | + }); | ||
| 143 | + } | ||
| 144 | + }) | ||
| 145 | + .catch(err => { | ||
| 146 | + console.error(err); | ||
| 147 | + }) | ||
| 148 | +}; | ||
| 89 | 149 | ||
| 90 | -// 自定义按钮颜色样式 | 150 | +/********** 切换用户功能 END *************/ |
| 91 | -const styleObject1 = reactive({ | ||
| 92 | - backgroundColor: '#FFFFFF', | ||
| 93 | - color: '#713610', | ||
| 94 | - borderColor: '#713610' | ||
| 95 | -}) | ||
| 96 | -const styleObject2 = reactive({ | ||
| 97 | - backgroundColor: '#FFFFFF', | ||
| 98 | - color: '#0B3A72', | ||
| 99 | - borderColor: '#0B3A72' | ||
| 100 | -}) | ||
| 101 | 151 | ||
| 152 | +// 查询用户信息 | ||
| 102 | const itemList = [ | 153 | const itemList = [ |
| 103 | { | 154 | { |
| 104 | name: '我的捐赠', | 155 | name: '我的捐赠', |
| 105 | - sum: '5', | 156 | + key: 'donate_num', |
| 157 | + sum: 0, | ||
| 106 | to: '/me/donateList' | 158 | to: '/me/donateList' |
| 107 | }, | 159 | }, |
| 108 | { | 160 | { |
| 109 | name: '我的作品', | 161 | name: '我的作品', |
| 110 | - sum: '5', | 162 | + key: 'prod_num', |
| 163 | + sum: 0, | ||
| 111 | to: '/me/videoList' | 164 | to: '/me/videoList' |
| 112 | }, | 165 | }, |
| 113 | { | 166 | { |
| 114 | name: '我的订阅', | 167 | name: '我的订阅', |
| 115 | - sum: '5', | 168 | + key: 'subs_num', |
| 169 | + sum: 0, | ||
| 116 | to: '/me/subscribe' | 170 | to: '/me/subscribe' |
| 117 | }, | 171 | }, |
| 118 | { | 172 | { |
| 119 | name: '我的收藏', | 173 | name: '我的收藏', |
| 120 | - sum: '5', | 174 | + key: 'favor_num', |
| 175 | + sum: 0, | ||
| 121 | to: '/me/collection' | 176 | to: '/me/collection' |
| 122 | }, | 177 | }, |
| 123 | { | 178 | { |
| 124 | name: '我的点赞', | 179 | name: '我的点赞', |
| 125 | - sum: '5', | 180 | + key: 'like_num', |
| 181 | + sum: 0, | ||
| 126 | to: '/me/like' | 182 | to: '/me/like' |
| 127 | }, | 183 | }, |
| 128 | { | 184 | { |
| 129 | name: '我的留言', | 185 | name: '我的留言', |
| 130 | - sum: '2', | 186 | + key: 'comment_num', |
| 187 | + sum: 0, | ||
| 131 | tag: true, | 188 | tag: true, |
| 132 | to: '/me/message' | 189 | to: '/me/message' |
| 133 | }, | 190 | }, |
| 134 | { | 191 | { |
| 135 | name: '@我的', | 192 | name: '@我的', |
| 136 | - sum: '2', | 193 | + key: 'reply_num', |
| 194 | + sum: 0, | ||
| 137 | tag: true, | 195 | tag: true, |
| 138 | to: '/me/callMe' | 196 | to: '/me/callMe' |
| 139 | }, | 197 | }, |
| 140 | ] | 198 | ] |
| 141 | 199 | ||
| 200 | +const userInfo = ref({}) | ||
| 201 | +axios.get('/srv/?a=my_info') | ||
| 202 | +.then(res => { | ||
| 203 | + if (res.data.code === 1) { | ||
| 204 | + userInfo.value = res.data.data; | ||
| 205 | + _.each(itemList, item => { | ||
| 206 | + item.sum = userInfo.value[item.key] | ||
| 207 | + }); | ||
| 208 | + } else { | ||
| 209 | + console.warn(res); | ||
| 210 | + Toast({ | ||
| 211 | + icon: 'close', | ||
| 212 | + message: res.data.msg | ||
| 213 | + }); | ||
| 214 | + } | ||
| 215 | +}) | ||
| 216 | +.catch(err => { | ||
| 217 | + console.error(err); | ||
| 218 | +}) | ||
| 219 | + | ||
| 220 | +/************************************************ */ | ||
| 221 | + | ||
| 222 | +// 跳转相关页面 | ||
| 223 | +const goTo = (path) => { | ||
| 224 | + $router.push({ | ||
| 225 | + path: path, | ||
| 226 | + query: { | ||
| 227 | + kg_id: userInfo.value.kg_id, | ||
| 228 | + kg_name: userInfo.value.kg_name | ||
| 229 | + } | ||
| 230 | + }) | ||
| 231 | +} | ||
| 232 | + | ||
| 233 | +// 自定义按钮颜色样式 | ||
| 234 | +const styleObject1 = reactive({ | ||
| 235 | + backgroundColor: '#FFFFFF', | ||
| 236 | + color: '#713610', | ||
| 237 | + borderColor: '#713610' | ||
| 238 | +}) | ||
| 239 | +const styleObject2 = reactive({ | ||
| 240 | + backgroundColor: '#FFFFFF', | ||
| 241 | + color: '#0B3A72', | ||
| 242 | + borderColor: '#0B3A72' | ||
| 243 | +}) | ||
| 244 | +const styleObject3 = reactive({ | ||
| 245 | + backgroundColor: '#FFFFFF', | ||
| 246 | + color: '#FDD347', | ||
| 247 | + borderColor: '#FDD347' | ||
| 248 | +}) | ||
| 249 | + | ||
| 142 | const getFollow = () => { | 250 | const getFollow = () => { |
| 143 | $router.push({ | 251 | $router.push({ |
| 144 | path: '/me/followList' | 252 | path: '/me/followList' |
| ... | @@ -149,10 +257,6 @@ const getUnwatch = () => { | ... | @@ -149,10 +257,6 @@ const getUnwatch = () => { |
| 149 | path: '/me/unwatchList' | 257 | path: '/me/unwatchList' |
| 150 | }) | 258 | }) |
| 151 | } | 259 | } |
| 152 | - | ||
| 153 | -onMounted(() => { | ||
| 154 | - | ||
| 155 | -}) | ||
| 156 | </script> | 260 | </script> |
| 157 | 261 | ||
| 158 | <script> | 262 | <script> |
| ... | @@ -201,6 +305,7 @@ export default { | ... | @@ -201,6 +305,7 @@ export default { |
| 201 | .address { | 305 | .address { |
| 202 | font-size: 0.85rem; | 306 | font-size: 0.85rem; |
| 203 | color: #999999; | 307 | color: #999999; |
| 308 | + opacity: 0.8; | ||
| 204 | } | 309 | } |
| 205 | } | 310 | } |
| 206 | .sub-data { | 311 | .sub-data { | ... | ... |
-
Please register or login to post a comment