index.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  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. await 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}`
  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. async searchToken() {
  87. const that = this;
  88. uni.getStorage({
  89. key: 'token',
  90. success: function(res) {
  91. that.$set(that, `user`, res.data);
  92. uni.getStorage({
  93. key: 'config',
  94. success: function(arr) {
  95. if (res.data.gender == '0') that.$set(that, `logo`,
  96. arr.data.boy_url[0].url);
  97. else if (res.data.gender == '1') that.$set(that, `logo`,
  98. arr.data.girl_url[0].url);
  99. else that.$set(that, `logo`, arr.data.logo_url[0].url ||
  100. '../../static/login.jpeg');
  101. }
  102. })
  103. let config = that.$config;
  104. that.$set(that, `orderList`, config.orderList);
  105. let menu = []
  106. for (let val of config.menuList) {
  107. const role = val.role.find((i) => i == that.user.role);
  108. if (role) menu.push(val)
  109. }
  110. that.$set(that, `menuList`, menu);
  111. },
  112. fail: function(err) {
  113. uni.showToast({
  114. title: err.errmsg,
  115. icon: 'error',
  116. duration: 2000
  117. });
  118. }
  119. })
  120. },
  121. async searchOther() {
  122. const that = this;
  123. }
  124. }
  125. }
  126. </script>
  127. <style lang="scss">
  128. .content {
  129. display: flex;
  130. flex-direction: column;
  131. .one {
  132. display: flex;
  133. align-items: center;
  134. background: repeating-linear-gradient(to bottom, var(--f3CColor), var(--mainColor));
  135. padding: 5vw;
  136. .logo {
  137. width: 15vw;
  138. height: 15vw;
  139. border-radius: 90px;
  140. }
  141. .one_1 {
  142. display: flex;
  143. flex-direction: column;
  144. padding: 0 2vw;
  145. .name {
  146. margin: 0 0 1vw 0;
  147. font-size: var(--font16Size);
  148. }
  149. .gender {
  150. color: var(--f85Color);
  151. font-size: var(--font13Size);
  152. }
  153. }
  154. }
  155. .two {
  156. display: flex;
  157. flex-direction: column;
  158. padding: 2vw;
  159. margin: 0 2vw;
  160. border-radius: 10px;
  161. background-color: var(--mianColor);
  162. .two_1 {
  163. display: flex;
  164. justify-content: space-between;
  165. padding: 2vw 0;
  166. border-bottom: 1px solid var(--f9Color);
  167. .left {
  168. font-weight: 600;
  169. font-size: var(--font14Size);
  170. }
  171. .right {
  172. display: flex;
  173. align-items: center;
  174. font-size: var(--font12Size);
  175. color: var(--f99Color);
  176. }
  177. }
  178. .two_2 {
  179. display: flex;
  180. justify-content: space-between;
  181. padding: 2vw 0;
  182. .list {
  183. display: flex;
  184. flex-direction: column;
  185. align-items: center;
  186. justify-content: center;
  187. text-align: center;
  188. .icon {
  189. .iconfont {
  190. font-size: 25px;
  191. }
  192. }
  193. .title {
  194. display: inline-block;
  195. margin: 2vw 0 0 0;
  196. font-size: var(--font12Size);
  197. }
  198. }
  199. }
  200. }
  201. .thr {
  202. display: flex;
  203. flex-direction: column;
  204. margin: 2vw;
  205. border-radius: 10px;
  206. background-color: var(--mianColor);
  207. .list {
  208. display: flex;
  209. justify-content: space-between;
  210. padding: 2vw;
  211. border-bottom: 1px solid var(--f9Color);
  212. .left {
  213. display: flex;
  214. align-items: center;
  215. font-size: var(--font12Size);
  216. .icon {
  217. padding: 0 2vw 0 0;
  218. .iconfont {
  219. color: var(--f3CColor);
  220. font-size: 20px;
  221. }
  222. }
  223. .title {
  224. display: inline-block;
  225. font-size: var(--font12Size);
  226. }
  227. }
  228. .right {
  229. display: flex;
  230. align-items: center;
  231. font-size: var(--font12Size);
  232. color: var(--f99Color);
  233. }
  234. }
  235. }
  236. }
  237. </style>