index.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. <template>
  2. <view class="content">
  3. <view class="one">
  4. <image class="logo" :src="logo"></image>
  5. <view class="one_1">
  6. <text class="name">{{user.name}}</text>
  7. <text class="gender">性别: {{user.gender=='0'?'男':user.gender=='1'?'女':'未知'}}</text>
  8. </view>
  9. </view>
  10. <view class="two">
  11. <view class="two_1">
  12. <view class="left">我的订单</view>
  13. <view class="right" @tap="toCommon('pagesMy/order/index')">查看全部订单 <text
  14. class="iconfont icon-dayuhao"></text></view>
  15. </view>
  16. <view class="two_2">
  17. <view class="list" v-for="(item,index) in orderList" :key="index" @tap="toRoute(item)">
  18. <uni-badge :text="item.num" absolute="rightTop" size="normal">
  19. <view class="icon">
  20. <text class="iconfont" :class="[item.icon]"></text>
  21. </view>
  22. <text class="title">{{item.title}}</text>
  23. </uni-badge>
  24. </view>
  25. </view>
  26. </view>
  27. <view class="thr">
  28. <view class="list" v-for="(item, index) in menuList" :key="index" @click="toCommon(item.route)">
  29. <view class="left">
  30. <view class="icon">
  31. <text class="iconfont" :class="[item.icon]"></text>
  32. </view>
  33. <text class="title">{{item.title}}</text>
  34. </view>
  35. <view class="right">
  36. <text class="iconfont icon-dayuhao"></text>
  37. </view>
  38. </view>
  39. </view>
  40. </view>
  41. </template>
  42. <script>
  43. export default {
  44. data() {
  45. return {
  46. logo: '',
  47. user: {},
  48. // 订单图标菜单
  49. orderList: [],
  50. // 菜单
  51. menuList: [],
  52. }
  53. },
  54. async onLoad() {
  55. const that = this;
  56. that.searchToken();
  57. await that.searchOther();
  58. },
  59. methods: {
  60. // 订单或维修跳转
  61. toRoute(item) {
  62. const that = this;
  63. if (that.user && that.user._id) {
  64. uni.navigateTo({
  65. url: `/${item.route}?status=${item.status}`
  66. })
  67. } else {
  68. uni.navigateTo({
  69. url: `/pages/login/index`
  70. })
  71. }
  72. },
  73. // 公共跳转
  74. toCommon(e) {
  75. const that = this;
  76. if (that.user && that.user._id) {
  77. uni.navigateTo({
  78. url: `/${e}`
  79. })
  80. } else {
  81. uni.navigateTo({
  82. url: `/pages/login/index`
  83. })
  84. }
  85. },
  86. searchToken() {
  87. const that = this;
  88. try {
  89. const res = uni.getStorageSync('token');
  90. if (res) that.$set(that, `user`, res);
  91. uni.getStorage({
  92. key: 'config',
  93. success: function(arr) {
  94. if (res.gender == '0') that.$set(that, `logo`,
  95. arr.data.boy_url[0].url);
  96. else if (res.gender == '1') that.$set(that, `logo`,
  97. arr.data.girl_url[0].url);
  98. else that.$set(that, `logo`, arr.data.logo_url[0].url ||
  99. '../../static/login.jpeg');
  100. }
  101. })
  102. } catch (e) {
  103. uni.showToast({
  104. title: err.errmsg,
  105. icon: 'error',
  106. duration: 2000
  107. });
  108. }
  109. },
  110. async searchOther() {
  111. const that = this;
  112. let config = that.$config;
  113. that.$set(that, `orderList`, config.orderList);
  114. let menu = []
  115. for (let val of config.menuList) {
  116. const role = val.role.find((i) => i == that.user.role);
  117. if (role) menu.push(val)
  118. }
  119. that.$set(that, `menuList`, menu);
  120. }
  121. }
  122. }
  123. </script>
  124. <style lang="scss">
  125. .content {
  126. display: flex;
  127. flex-direction: column;
  128. .one {
  129. display: flex;
  130. align-items: center;
  131. background: repeating-linear-gradient(to bottom, var(--f3CColor), var(--mainColor));
  132. padding: 5vw;
  133. .logo {
  134. width: 15vw;
  135. height: 15vw;
  136. border-radius: 90px;
  137. }
  138. .one_1 {
  139. display: flex;
  140. flex-direction: column;
  141. padding: 0 2vw;
  142. .name {
  143. margin: 0 0 1vw 0;
  144. font-size: var(--font16Size);
  145. }
  146. .gender {
  147. color: var(--f85Color);
  148. font-size: var(--font13Size);
  149. }
  150. }
  151. }
  152. .two {
  153. display: flex;
  154. flex-direction: column;
  155. padding: 2vw;
  156. margin: 0 2vw;
  157. border-radius: 10px;
  158. background-color: var(--mianColor);
  159. .two_1 {
  160. display: flex;
  161. justify-content: space-between;
  162. padding: 2vw 0;
  163. border-bottom: 1px solid var(--f9Color);
  164. .left {
  165. font-weight: 600;
  166. font-size: var(--font14Size);
  167. }
  168. .right {
  169. display: flex;
  170. align-items: center;
  171. font-size: var(--font12Size);
  172. color: var(--f99Color);
  173. }
  174. }
  175. .two_2 {
  176. display: flex;
  177. justify-content: space-between;
  178. padding: 2vw 0;
  179. .list {
  180. display: flex;
  181. flex-direction: column;
  182. align-items: center;
  183. justify-content: center;
  184. text-align: center;
  185. .icon {
  186. .iconfont {
  187. font-size: 25px;
  188. }
  189. }
  190. .title {
  191. display: inline-block;
  192. margin: 2vw 0 0 0;
  193. font-size: var(--font12Size);
  194. }
  195. }
  196. }
  197. }
  198. .thr {
  199. display: flex;
  200. flex-direction: column;
  201. margin: 2vw;
  202. border-radius: 10px;
  203. background-color: var(--mianColor);
  204. .list {
  205. display: flex;
  206. justify-content: space-between;
  207. padding: 2vw;
  208. border-bottom: 1px solid var(--f9Color);
  209. .left {
  210. display: flex;
  211. align-items: center;
  212. font-size: var(--font12Size);
  213. .icon {
  214. padding: 0 2vw 0 0;
  215. .iconfont {
  216. color: var(--f3CColor);
  217. font-size: 20px;
  218. }
  219. }
  220. .title {
  221. display: inline-block;
  222. font-size: var(--font12Size);
  223. }
  224. }
  225. .right {
  226. display: flex;
  227. align-items: center;
  228. font-size: var(--font12Size);
  229. color: var(--f99Color);
  230. }
  231. }
  232. }
  233. }
  234. </style>