index.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  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(`pagesIndex/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. title: '点赞',
  64. route: 'pagesIndex/like/index',
  65. type: '0',
  66. num: 0,
  67. },
  68. {
  69. title: '收藏',
  70. route: 'pagesIndex/collect/index',
  71. type: '1',
  72. num: 0,
  73. },
  74. {
  75. title: '评论',
  76. route: 'pagesIndex/comment/index',
  77. type: '2',
  78. num: 0,
  79. },
  80. ],
  81. // 订单图标菜单
  82. orderList: [],
  83. // 菜单
  84. menuList: []
  85. }
  86. },
  87. onLoad: async function() {
  88. const that = this;
  89. await that.searchOther();
  90. },
  91. onShow: async function(e) {
  92. const that = this;
  93. that.searchToken();
  94. await that.search();
  95. },
  96. methods: {
  97. searchToken() {
  98. const that = this;
  99. try {
  100. const res = uni.getStorageSync('token');
  101. if (res) that.$set(that, `user`, res);
  102. } catch (e) {
  103. uni.showToast({
  104. title: err.errmsg,
  105. icon: 'error',
  106. duration: 2000
  107. });
  108. }
  109. },
  110. // 查询
  111. async search() {
  112. const that = this;
  113. let res;
  114. res = await that.$api(`/user/statistics`, 'GET', {
  115. user: that.user._id
  116. })
  117. if (res.errcode == '0') {
  118. that.$set(that, `list`, res.data)
  119. } else {
  120. uni.showToast({
  121. title: res.errmsg,
  122. });
  123. }
  124. },
  125. // 登录或注册
  126. async toLogin() {
  127. uni.navigateTo({
  128. url: `/pagesIndex/login/index`
  129. })
  130. },
  131. // 点赞或收藏
  132. toLike(item) {
  133. const that = this;
  134. if (that.user && that.user._id) {
  135. if (item.type == '2') {
  136. uni.navigateTo({
  137. url: `/${item.route}`
  138. })
  139. } else {
  140. uni.navigateTo({
  141. url: `/${item.route}?type=${item.type}`
  142. })
  143. }
  144. } else {
  145. uni.navigateTo({
  146. url: `/pagesIndex/login/index`
  147. })
  148. }
  149. },
  150. // 订单或维修跳转
  151. toRoute(item) {
  152. const that = this;
  153. if (that.user && that.user._id) {
  154. uni.navigateTo({
  155. url: `/${item.route}?status=${item.status}`
  156. })
  157. } else {
  158. uni.navigateTo({
  159. url: `/pagesIndex/login/index`
  160. })
  161. }
  162. },
  163. // 公共跳转
  164. toCommon(e) {
  165. const that = this;
  166. if (that.user && that.user._id) {
  167. uni.navigateTo({
  168. url: `/${e}`
  169. })
  170. } else {
  171. uni.navigateTo({
  172. url: `/pagesIndex/login/index`
  173. })
  174. }
  175. },
  176. async searchOther() {
  177. const that = this;
  178. let config = that.$config;
  179. that.$set(that, `orderList`, config.orderList);
  180. that.$set(that, `menuList`, config.menuList);
  181. }
  182. }
  183. }
  184. </script>
  185. <style lang="scss" scoped>
  186. .main {
  187. display: flex;
  188. flex-direction: column;
  189. width: 100vw;
  190. height: 100vh;
  191. background-image: linear-gradient(to top, rgba(241, 241, 241, 1), rgba(241, 241, 241, 1), rgba(0, 122, 255, 1));
  192. .one {
  193. .one_1 {
  194. padding: 4vw;
  195. .top {
  196. display: flex;
  197. align-items: center;
  198. font-size: var(--font18Size);
  199. .image {
  200. width: 15vw;
  201. height: 15vw;
  202. border-radius: 15vw;
  203. margin: 0 2vw;
  204. }
  205. .iconfont {
  206. font-size: 40px;
  207. color: var(--f85Color);
  208. padding: 2vw;
  209. }
  210. }
  211. }
  212. .one_2 {
  213. padding: 5vw;
  214. .bottom {
  215. display: flex;
  216. justify-content: space-around;
  217. .list {
  218. display: flex;
  219. flex-direction: column;
  220. align-items: center;
  221. }
  222. }
  223. }
  224. }
  225. .two {
  226. display: flex;
  227. flex-direction: column;
  228. padding: 2vw;
  229. margin: 2vw;
  230. border-radius: 10px;
  231. background-color: var(--mainColor);
  232. .two_1 {
  233. display: flex;
  234. justify-content: space-between;
  235. padding: 2vw;
  236. border-bottom: 1px solid var(--f9Color);
  237. .left {
  238. font-weight: 600;
  239. font-size: var(--font14Size);
  240. }
  241. .right {
  242. display: flex;
  243. align-items: center;
  244. font-size: var(--font12Size);
  245. color: var(--f99Color);
  246. }
  247. }
  248. .two_2 {
  249. display: flex;
  250. justify-content: space-between;
  251. padding: 3vw 4vw;
  252. .list {
  253. display: flex;
  254. flex-direction: column;
  255. align-items: center;
  256. justify-content: center;
  257. text-align: center;
  258. .icon {
  259. .iconfont {
  260. font-size: 25px;
  261. }
  262. }
  263. .title {
  264. display: inline-block;
  265. margin: 1vw 0 0 0;
  266. font-size: var(--font12Size);
  267. }
  268. }
  269. }
  270. }
  271. .thr {
  272. display: flex;
  273. flex-direction: column;
  274. padding: 2vw;
  275. margin: 0 2vw;
  276. border-radius: 10px;
  277. background-color: var(--mainColor);
  278. .list {
  279. display: flex;
  280. justify-content: space-between;
  281. padding: 2vw;
  282. border-bottom: 1px solid var(--f9Color);
  283. .left {
  284. display: flex;
  285. align-items: center;
  286. font-size: var(--font12Size);
  287. .icon {
  288. padding: 0 1vw 0 0;
  289. .iconfont {
  290. color: var(--f3CColor);
  291. font-size: var(--font18Size);
  292. }
  293. }
  294. .title {
  295. display: inline-block;
  296. font-size: var(--font12Size);
  297. }
  298. }
  299. .right {
  300. display: flex;
  301. align-items: center;
  302. font-size: var(--font12Size);
  303. color: var(--f99Color);
  304. }
  305. }
  306. }
  307. }
  308. </style>