index.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <template>
  2. <view class="content">
  3. <view class="one">
  4. <view class="one_1" v-if="user&&user._id">
  5. <view class="left">
  6. <image v-if="user&&user.icon&&user.icon.length>0" class="logo" :src="user.icon[0].url"></image>
  7. <image v-else class="logo" :src="config.icon[0].url"></image>
  8. </view>
  9. <view class="right">
  10. <view class="name">{{user.nick_name||'暂无昵称'}}</view>
  11. <view class="gender">性别:{{getGender(user.gender)}}</view>
  12. </view>
  13. </view>
  14. <view class="one_1" v-else>
  15. <view class="left">
  16. <image class="logo" :src="config.icon[0].url"></image>
  17. </view>
  18. <view class="right">
  19. <view class="name" @click="show=true">点击登录</view>
  20. </view>
  21. </view>
  22. </view>
  23. <view class="two">
  24. <view class="two_1">
  25. <view class="left">我的订单</view>
  26. <view class="right" @tap="toCommon(`pagesMy/order/index?status=${'-1'}`)">查看全部订单
  27. <up-icon name="arrow-right" size="16"></up-icon>
  28. </view>
  29. </view>
  30. <view class="two_2">
  31. <view class="list" v-for="(item,index) in configInfo.orderList" :key="index" @tap="toRoute(item)">
  32. <uni-badge :text="item.num" absolute="rightTop" size="normal">
  33. <view class="icon">
  34. <text class="t-icon" :class="[item.icon]"></text>
  35. </view>
  36. <text class="title">{{item.title}}</text>
  37. </uni-badge>
  38. </view>
  39. </view>
  40. </view>
  41. <view class="thr">
  42. <view class="list" v-for="(item, index) in menuList" :key="index" @click="toCommon(item.route)">
  43. <view class="left">
  44. <view class="icon">
  45. <text class="t-icon" :class="[item.icon]"></text>
  46. </view>
  47. <text class="title">{{item.title}}</text>
  48. </view>
  49. <view class="right">
  50. <up-icon name="arrow-right" size="16"></up-icon>
  51. </view>
  52. </view>
  53. </view>
  54. <up-overlay :show="show">
  55. <login @showChange='showChange'></login>
  56. </up-overlay>
  57. </view>
  58. </template>
  59. <script setup lang="ts">
  60. import configInfo from '../../config.js';
  61. import login from "@/components/login.vue"
  62. import { inject, computed, ref } from 'vue';
  63. //该依赖已内置不需要单独安装
  64. import { onShow, onPullDownRefresh } from "@dcloudio/uni-app";
  65. // 请求接口
  66. const $api = inject('$api');
  67. const $config = inject('$config');
  68. // 基本信息
  69. const config = ref({ logo: [], icon: [], file: [] });
  70. // 遮罩层
  71. const show = ref(false);
  72. const user = ref({ icon: [] });
  73. // 字典表
  74. const genderList = ref([]);
  75. // 菜单
  76. const menuList = ref([]);
  77. onShow(async () => {
  78. await searchConfig();
  79. await searchUser();
  80. await searchOther();
  81. await search();
  82. if (!user.value) show.value = true
  83. })
  84. // user信息
  85. const searchUser = async () => {
  86. user.value = uni.getStorageSync('user');
  87. };
  88. // config信息
  89. const searchConfig = async () => {
  90. config.value = uni.getStorageSync('config');
  91. };
  92. // 其他查询信息
  93. const searchOther = async () => {
  94. let res;
  95. // 性别
  96. res = await $api(`dictData`, 'GET', { code: 'gender', is_use: '0' });
  97. if (res.errcode === 0) genderList.value = res.data;
  98. // 菜单
  99. let menu = []
  100. for (let val of $config.menuList) {
  101. const role = val.role.find((i) => i == user.value.role_type);
  102. if (role) menu.push(val)
  103. }
  104. menuList.value = menu
  105. };
  106. // 查询
  107. const search = async () => { };
  108. const showChange = () => {
  109. show.value = false
  110. }
  111. const getGender = (i) => {
  112. if (i) {
  113. const r = genderList.value.find((f) => f.value === i)
  114. if (r) return r.label
  115. else return '暂无'
  116. } else return '暂无'
  117. }
  118. // 订单
  119. const toRoute = (item) => {
  120. if (user.value && user.value._id) {
  121. uni.navigateTo({
  122. url: `/${item.route}?status=${item.status}`
  123. })
  124. } else show.value = true
  125. }
  126. // 公共跳转
  127. const toCommon = (e) => {
  128. if (user.value && user.value._id) {
  129. uni.navigateTo({
  130. url: `/${e}`
  131. })
  132. } else show.value = true
  133. }
  134. </script>
  135. <style lang="scss" scoped>
  136. .content {
  137. display: flex;
  138. flex-direction: column;
  139. width: 100vw;
  140. height: 100vh;
  141. background: linear-gradient(to bottom, #3c9cff, #f1f1f1);
  142. .one {
  143. padding: 5vw;
  144. .one_1 {
  145. display: flex;
  146. align-items: center;
  147. .left {
  148. margin: 0 2vw 0 0;
  149. .logo {
  150. width: 15vw;
  151. height: 15vw;
  152. border-radius: 90px;
  153. }
  154. }
  155. .right {
  156. color: var(--mainColor);
  157. .name {
  158. font-size: var(--font16Size);
  159. margin: 0 0 2vw 0;
  160. }
  161. .gender {
  162. font-size: var(--font14Size);
  163. }
  164. }
  165. }
  166. }
  167. .two {
  168. display: flex;
  169. flex-direction: column;
  170. padding: 3vw;
  171. margin: 2vw;
  172. border-radius: 10px;
  173. background-color: var(--mainColor);
  174. .two_1 {
  175. display: flex;
  176. justify-content: space-between;
  177. align-items: center;
  178. padding: 0 0 2vw 0;
  179. border-bottom: 1px solid var(--f9Color);
  180. .left {
  181. font-weight: 600;
  182. font-size: var(--font16Size);
  183. }
  184. .right {
  185. display: flex;
  186. align-items: center;
  187. font-size: var(--font14Size);
  188. color: var(--f99Color);
  189. }
  190. }
  191. .two_2 {
  192. display: flex;
  193. justify-content: space-between;
  194. padding: 2vw;
  195. .list {
  196. text-align: center;
  197. .title {
  198. display: inline-block;
  199. margin: 1vw 0 0 0;
  200. font-size: var(--font14Size);
  201. }
  202. }
  203. }
  204. }
  205. .thr {
  206. display: flex;
  207. flex-direction: column;
  208. margin: 2vw;
  209. border-radius: 10px;
  210. background-color: var(--mainColor);
  211. .list {
  212. display: flex;
  213. justify-content: space-between;
  214. padding: 3vw;
  215. border-bottom: 1px solid var(--f9Color);
  216. .left {
  217. display: flex;
  218. font-size: var(--font14Size);
  219. .icon {
  220. padding: 0 2vw 0 0;
  221. }
  222. .title {
  223. display: inline-block;
  224. font-size: var(--font14Size);
  225. }
  226. }
  227. .right {
  228. display: flex;
  229. align-items: center;
  230. font-size: var(--font14Size);
  231. color: var(--f99Color);
  232. }
  233. }
  234. .list:last-child {
  235. border: none;
  236. }
  237. }
  238. }
  239. </style>