index.vue 6.1 KB

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