index.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317
  1. <template>
  2. <view class="main">
  3. <view class="one">
  4. <view class="one_1">
  5. <view v-if="user._id" class="top">
  6. <image class="image" :src="user.logo&&user.logo.length>0?user.logo[0].url:'../../static/my.png'"
  7. mode=""></image>
  8. <text>{{user.nick_name||'微信用户'}}</text>
  9. </view>
  10. <view v-else class="top" @tap="toLogin">
  11. <text class="iconfont icon-yonghu"></text>
  12. <text>登录/注册</text>
  13. </view>
  14. </view>
  15. <view class="one_2">
  16. <view class="bottom">
  17. <view class="list" v-for="(item,index) in list" :key="index" @tap="toLike(item)">
  18. <text>{{item.num}}</text>
  19. <text>{{item.title}}</text>
  20. </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`)">查看全部订单 <text
  28. class="iconfont icon-dayuhao"></text></view>
  29. </view>
  30. <view class="two_2">
  31. <view class="list" v-for="(item,index) in orderList" :key="index" @tap="toRoute(item)">
  32. <uni-badge :text="item.num" absolute="rightTop" size="normal">
  33. <view class="icon">
  34. <text class="iconfont" :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="iconfont" :class="[item.icon]"></text>
  46. </view>
  47. <text class="title">{{item.title}}</text>
  48. </view>
  49. <view class="right">
  50. <text class="iconfont icon-dayuhao"></text>
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. </template>
  56. <script>
  57. export default {
  58. data() {
  59. return {
  60. user: {},
  61. // 获赞数
  62. list: [],
  63. // 订单图标菜单
  64. orderList: [],
  65. // 菜单
  66. menuList: []
  67. }
  68. },
  69. onLoad: async function() {
  70. const that = this;
  71. await that.searchOther();
  72. },
  73. onShow: async function(e) {
  74. const that = this;
  75. that.searchToken();
  76. await that.search();
  77. },
  78. methods: {
  79. searchToken() {
  80. const that = this;
  81. try {
  82. const res = uni.getStorageSync('token');
  83. if (res) that.$set(that, `user`, res);
  84. } catch (e) {
  85. uni.showToast({
  86. title: err.errmsg,
  87. icon: 'error',
  88. duration: 2000
  89. });
  90. }
  91. },
  92. // 查询
  93. async search() {
  94. const that = this;
  95. let res;
  96. res = await that.$api(`/user/statistics`, 'GET', {
  97. user: that.user._id
  98. })
  99. if (res.errcode == '0') {
  100. that.$set(that, `list`, res.data)
  101. } else {
  102. uni.showToast({
  103. title: res.errmsg,
  104. });
  105. }
  106. },
  107. // 登录或注册
  108. async toLogin() {
  109. uni.navigateTo({
  110. url: `/pagesIndex/login/index`
  111. })
  112. },
  113. // 点赞或收藏
  114. toLike(item) {
  115. const that = this;
  116. if (that.user && that.user._id) {
  117. if (item.type == '2') {
  118. uni.navigateTo({
  119. url: `/${item.route}`
  120. })
  121. } else {
  122. uni.navigateTo({
  123. url: `/${item.route}?type=${item.type}`
  124. })
  125. }
  126. } else {
  127. uni.navigateTo({
  128. url: `/pagesIndex/login/index`
  129. })
  130. }
  131. },
  132. // 订单或维修跳转
  133. toRoute(item) {
  134. const that = this;
  135. if (that.user && that.user._id) {
  136. uni.navigateTo({
  137. url: `/${item.route}?status=${item.status}`
  138. })
  139. } else {
  140. uni.navigateTo({
  141. url: `/pagesIndex/login/index`
  142. })
  143. }
  144. },
  145. // 公共跳转
  146. toCommon(e) {
  147. const that = this;
  148. if (that.user && that.user._id) {
  149. uni.navigateTo({
  150. url: `/${e}`
  151. })
  152. } else {
  153. uni.navigateTo({
  154. url: `/pagesIndex/login/index`
  155. })
  156. }
  157. },
  158. async searchOther() {
  159. const that = this;
  160. let config = that.$config;
  161. that.$set(that, `orderList`, config.orderList);
  162. that.$set(that, `menuList`, config.menuList);
  163. }
  164. }
  165. }
  166. </script>
  167. <style lang="scss" scoped>
  168. .main {
  169. display: flex;
  170. flex-direction: column;
  171. width: 100vw;
  172. height: 100vh;
  173. background-color: var(--footColor);
  174. .one {
  175. background-image: linear-gradient(181.2deg, #FEFEFE 10.5%, #87CEFA 86.8%);
  176. height: 45vw;
  177. .one_1 {
  178. padding: 4vw;
  179. .top {
  180. display: flex;
  181. align-items: center;
  182. font-size: var(--font18Szie);
  183. .image {
  184. width: 15vw;
  185. height: 15vw;
  186. border-radius: 15vw;
  187. margin: 0 2vw;
  188. }
  189. .iconfont {
  190. font-size: 40px;
  191. color: var(--f85Color);
  192. padding: 2vw;
  193. }
  194. }
  195. }
  196. .one_2 {
  197. padding: 5vw;
  198. .bottom {
  199. display: flex;
  200. justify-content: space-around;
  201. .list {
  202. display: flex;
  203. flex-direction: column;
  204. align-items: center;
  205. }
  206. }
  207. }
  208. }
  209. .two {
  210. display: flex;
  211. flex-direction: column;
  212. padding: 2vw;
  213. margin: 2vw;
  214. border-radius: 10px;
  215. background-color: var(--mainColor);
  216. .two_1 {
  217. display: flex;
  218. justify-content: space-between;
  219. padding: 2vw;
  220. border-bottom: 1px solid var(--f9Color);
  221. .left {
  222. font-weight: 600;
  223. font-size: var(--font14Size);
  224. }
  225. .right {
  226. display: flex;
  227. align-items: center;
  228. font-size: var(--font12Size);
  229. color: var(--f99Color);
  230. }
  231. }
  232. .two_2 {
  233. display: flex;
  234. justify-content: space-between;
  235. padding: 3vw 4vw;
  236. .list {
  237. display: flex;
  238. flex-direction: column;
  239. align-items: center;
  240. justify-content: center;
  241. text-align: center;
  242. .icon {
  243. .iconfont {
  244. font-size: 25px;
  245. }
  246. }
  247. .title {
  248. display: inline-block;
  249. margin: 1vw 0 0 0;
  250. font-size: var(--font12Size);
  251. }
  252. }
  253. }
  254. }
  255. .thr {
  256. display: flex;
  257. flex-direction: column;
  258. padding: 2vw;
  259. margin: 0 2vw;
  260. border-radius: 10px;
  261. background-color: var(--mainColor);
  262. .list {
  263. display: flex;
  264. justify-content: space-between;
  265. padding: 2vw;
  266. border-bottom: 1px solid var(--f9Color);
  267. .left {
  268. display: flex;
  269. align-items: center;
  270. font-size: var(--font12Size);
  271. .icon {
  272. padding: 0 1vw 0 0;
  273. .iconfont {
  274. color: var(--f3CColor);
  275. font-size: var(--font18Szie);
  276. }
  277. }
  278. .title {
  279. display: inline-block;
  280. font-size: var(--font12Size);
  281. }
  282. }
  283. .right {
  284. display: flex;
  285. align-items: center;
  286. font-size: var(--font12Size);
  287. color: var(--f99Color);
  288. }
  289. }
  290. }
  291. }
  292. </style>