index.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  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.icon&&user.icon.length>0&&user.icon" 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 configInfo.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. onShow(async () => {
  76. await searchConfig();
  77. await searchUser();
  78. await searchOther();
  79. await search();
  80. if (!user.value) show.value = true
  81. })
  82. // user信息
  83. const searchUser = async () => {
  84. user.value = uni.getStorageSync('user');
  85. };
  86. // config信息
  87. const searchConfig = async () => {
  88. config.value = uni.getStorageSync('config');
  89. };
  90. // 其他查询信息
  91. const searchOther = async () => {
  92. let res;
  93. // 性别
  94. res = await $api(`dictData`, 'GET', { code: 'gender', is_use: '0' });
  95. if (res.errcode === 0) genderList.value = res.data;
  96. };
  97. // 查询
  98. const search = async () => { };
  99. const showChange = () => {
  100. show.value = false
  101. }
  102. const getGender = (i) => {
  103. if (i) {
  104. const r = genderList.value.find((f) => f.value === i)
  105. if (r) return r.label
  106. else return '暂无'
  107. } else return '暂无'
  108. }
  109. // 订单
  110. const toRoute = (item) => {
  111. if (user.value && user.value._id) {
  112. uni.navigateTo({
  113. url: `/${item.route}?status=${item.status}`
  114. })
  115. } else show.value = true
  116. }
  117. // 公共跳转
  118. const toCommon = (e) => {
  119. if (user.value && user.value._id) {
  120. uni.navigateTo({
  121. url: `/${e}`
  122. })
  123. } else show.value = true
  124. }
  125. </script>
  126. <style lang="scss" scoped>
  127. .content {
  128. display: flex;
  129. flex-direction: column;
  130. width: 100vw;
  131. height: 100vh;
  132. background: linear-gradient(to bottom, #3c9cff, #f1f1f1);
  133. .one {
  134. padding: 5vw;
  135. .one_1 {
  136. display: flex;
  137. align-items: center;
  138. .left {
  139. margin: 0 2vw 0 0;
  140. .logo {
  141. width: 15vw;
  142. height: 15vw;
  143. border-radius: 90px;
  144. }
  145. }
  146. .right {
  147. color: var(--mainColor);
  148. .name {
  149. font-size: var(--font16Size);
  150. margin: 0 0 2vw 0;
  151. }
  152. .gender {
  153. font-size: var(--font14Size);
  154. }
  155. }
  156. }
  157. }
  158. .two {
  159. display: flex;
  160. flex-direction: column;
  161. padding: 3vw;
  162. margin: 2vw;
  163. border-radius: 10px;
  164. background-color: var(--mainColor);
  165. .two_1 {
  166. display: flex;
  167. justify-content: space-between;
  168. align-items: center;
  169. padding: 0 0 2vw 0;
  170. border-bottom: 1px solid var(--f9Color);
  171. .left {
  172. font-weight: 600;
  173. font-size: var(--font16Size);
  174. }
  175. .right {
  176. display: flex;
  177. align-items: center;
  178. font-size: var(--font14Size);
  179. color: var(--f99Color);
  180. }
  181. }
  182. .two_2 {
  183. display: flex;
  184. justify-content: space-between;
  185. padding: 2vw 0;
  186. .list {
  187. display: flex;
  188. flex-direction: column;
  189. align-items: center;
  190. justify-content: center;
  191. text-align: center;
  192. .title {
  193. display: inline-block;
  194. margin: 1vw 0 0 0;
  195. font-size: var(--font14Size);
  196. }
  197. }
  198. }
  199. }
  200. .thr {
  201. display: flex;
  202. flex-direction: column;
  203. margin: 2vw;
  204. border-radius: 10px;
  205. background-color: var(--mainColor);
  206. .list {
  207. display: flex;
  208. justify-content: space-between;
  209. padding: 3vw;
  210. border-bottom: 1px solid var(--f9Color);
  211. .left {
  212. display: flex;
  213. align-items: center;
  214. font-size: var(--font14Size);
  215. .icon {
  216. padding: 0 2vw 0 0;
  217. }
  218. .title {
  219. display: inline-block;
  220. font-size: var(--font14Size);
  221. }
  222. }
  223. .right {
  224. display: flex;
  225. align-items: center;
  226. font-size: var(--font14Size);
  227. color: var(--f99Color);
  228. }
  229. }
  230. .list:last-child {
  231. border: none;
  232. }
  233. }
  234. }
  235. </style>