index.vue 6.6 KB

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