index.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. <template>
  2. <view class="index-index">
  3. <custom-nav ref="ltm" :title="title" transparent="transparent" noback="noback"></custom-nav>
  4. <view class="content">
  5. <view class="area manage">
  6. <navigator v-for="(item, index) in namageList" :url="item.url" :key="index">
  7. <image :src="item.image"></image>
  8. <text>{{ item.name }}</text>
  9. </navigator>
  10. </view>
  11. <view class="area swiper">
  12. <swiper :autoplay="true" :circular="true" :interval="3456" :duration="345">
  13. <swiper-item v-for="(item, index) in swiper" :key="index" @tap="toSwiperDetail(index)">
  14. <image :src="item.imgurl"></image>
  15. </swiper-item>
  16. </swiper>
  17. </view>
  18. <view class="area news" v-if="news.length">
  19. <image src="../../static/index/index/news.png"></image>
  20. <view class="hot">热点</view>
  21. <swiper :vertical="true" :autoplay="true" :circular="true" :interval="3456" :duration="345">
  22. <swiper-item class="ellipsis" v-for="(item, index) in news" :key="index">
  23. {{ item.contents}}
  24. </swiper-item>
  25. </swiper>
  26. </view>
  27. <view class="area kingkong">
  28. <navigator v-for="(item, index) in kingkongList" :url="item.url" :key="index">
  29. <image :src="item.image"></image>
  30. <text>{{ item.name }}</text>
  31. </navigator>
  32. </view>
  33. </view>
  34. </view>
  35. </template>
  36. <script>
  37. import { deepClone } from '@/common/util/index.js'
  38. import { _API_InviteCode } from '@/apis/team.js'
  39. import { _API_IndexIndex, _API_AppUpdata, _API_DownLoadNewVersion } from '@/apis/app.js'
  40. import { _API_GetUserStatus, _API_GetUserInfo, _API_ConfireLevel } from '@/apis/user.js'
  41. export default {
  42. data() {
  43. return {
  44. title: '首页',
  45. namageList: [
  46. {
  47. name: '订单管理',
  48. url: '../../pages/manage-order/manage-order',
  49. image: '../../static/index/index/manage-order.png'
  50. },
  51. {
  52. name: '人员管理',
  53. url: '../../pages/manage-people/manage-people',
  54. image: '../../static/index/index/manage-poeple.png'
  55. },
  56. {
  57. name: '财富管理',
  58. url: '../../pages/manage-money/manage-money',
  59. image: '../../static/index/index/manage-money.png'
  60. }
  61. ],
  62. news: {},
  63. swiper: [],
  64. article: {},
  65. invite_code: '',
  66. }
  67. },
  68. computed: {
  69. kingkongList() {
  70. const data = deepClone(this.$store.state.userinfo)
  71. delete data.avatar
  72. return [
  73. {
  74. name: '订货下单',
  75. url: '../../pages/place-order/place-order',
  76. image: '../../static/index/index/place-order.png'
  77. },
  78. {
  79. name: '我的订单',
  80. url: '../../pages/my-order/my-order',
  81. image: '../../static/index/index/my-order.png'
  82. },
  83. {
  84. name: '下级订单',
  85. url: '../../pages/down-order/down-order',
  86. image: '../../static/index/index/down-order.png'
  87. },
  88. {
  89. name: '我的库存',
  90. url: '../../pages/my-storage/my-storage',
  91. image: '../../static/index/index/my-stock.png'
  92. },
  93. {
  94. name: '邀请代理',
  95. url: `../../pages/invite-proxy/invite-proxy?data=${JSON.stringify(data)}`,
  96. image: '../../static/index/index/invite-proxy.png'
  97. },
  98. {
  99. name: '注册审核',
  100. url: '../../pages/register-examine/register-examine',
  101. image: '../../static/index/index/register-examine.png'
  102. },
  103. {
  104. name: '我的邀请',
  105. url: '../../pages/my-invite/my-invite',
  106. image: '../../static/index/index/my-invite.png'
  107. },
  108. {
  109. name: '团队管理',
  110. url: '../../pages/team-manage/team-manage',
  111. image: '../../static/index/index/team-manage.png'
  112. }
  113. ]
  114. }
  115. },
  116. onLoad() {
  117. uni.$on('noopening', () => uni.showToast({ title: '暂未开放', icon: 'none' }))
  118. // if (!this.$store.state.app.token) { //
  119. // if (location.search.length > 24 && decodeURIComponent) {
  120. // uni.reLaunch({ url: `../invite-proxy/invite-proxy?data=${JSON.stringify({
  121. // nickname: decodeURIComponent(location.search.replace(/^\?/, '').split('&')[0].split('=')[1]),
  122. // mobile: decodeURIComponent(location.search.replace(/^\?/, '').split('&')[1].split('=')[1]),
  123. // invite_code: decodeURIComponent(location.search.replace(/^\?/, '').split('&')[2].split('=')[1]),
  124. // })}` })
  125. // return
  126. // }
  127. // uni.reLaunch({ url: '../login-psw/login-psw' }) // 跳转到登陆
  128. // return
  129. // }
  130. },
  131. mounted() { // 页面创建后判断用户状态
  132. uni.$on('RELAUNCH', () => uni.reLaunch({ url: '../login-psw/login-psw' })) // 监听 token 失效事件,跳转到登录页
  133. if (this.$store.state.app.token) { // 当用户处于登陆状态
  134. uni.showLoading({ mask: true })
  135. _API_GetUserStatus().then(res => { // 获取用户状态
  136. this.$store.commit('userinfo/UPDATA_USERINFO', res.data) // 获取用户状态后保存在 vuex 中
  137. if (res.data.status == 1) { // 用户状态为 1 表示正常
  138. if (res.data.cert_status == 0) { // 用户认证状态为 0 表示 已注册 未填写信息
  139. this.indexRequest() // 请求首页数据
  140. uni.reLaunch({ url: '../auth-identity/auth-identity' })
  141. } else if (res.data.cert_status > 0 && res.data.cert_status < 6) { // 用户为认证状态
  142. uni.reLaunch({ url: '../auth-progress/auth-progress' }) // 跳转到用户认证进度页面
  143. } else if (res.data.cert_status == 6) { // 用户认证完成
  144. this.indexRequest() // 请求首页数据
  145. _API_GetUserInfo().then(res => { // 请求用户信息
  146. this.$store.commit('userinfo/UPDATA_USERINFO', res.data) // 获取用户信息后保存在 vuex 中
  147. console.log(this.$store.state.userinfo.pass_status)
  148. if (this.$store.state.userinfo.pass_status) {
  149. uni.showModal({ title: '提示', content: '为了保障您的账户安全,请立即修改密码', showCancel: false, success: res => {
  150. uni.reLaunch({ url: '../updata-psw/updata-psw' })
  151. }})
  152. }
  153. })
  154. _API_InviteCode().then(res => {
  155. this.$store.commit('userinfo/UPDATA_USERINFO', { invite_code: res.data.invite_code.toUpperCase() }) // 获取用户邀请码后保存在 vuex 中
  156. })
  157. }
  158. } else if (res.data.status == 0) { // 用户状态为 0 表示用户已被冻结
  159. this.$store.commit('app/LOGOUT')
  160. this.$refs.ltm.modal('提示', ['您已退出大卫博士'], 'noCancle').then(() => {
  161. uni.reLaunch({ url: '../login-reg/login-reg' })
  162. })
  163. }
  164. })
  165. } else {
  166. if (window.location.pathname.split('/').length > 4) {
  167. uni.showLoading({ mask: true })
  168. setTimeout(() => {
  169. uni.hideLoading()
  170. uni.reLaunch({ url: `../invite-proxy/invite-proxy?data=${JSON.stringify({
  171. nickname: decodeURIComponent(window.location.pathname.split('/')[3]),
  172. mobile: decodeURIComponent(window.location.pathname.split('/')[4]),
  173. invite_code: decodeURIComponent(window.location.pathname.split('/')[5])
  174. })}` })
  175. }, 888)
  176. } else {
  177. uni.reLaunch({ url: '../login-psw/login-psw' })
  178. }
  179. }
  180. },
  181. methods: {
  182. rTap() { uni.navigateTo({ url: '../help-use/help-use' }) }, // 点击导航栏帮助
  183. toSwiperDetail(index) { // 点击轮播图
  184. if (this.swiper[index].is_jump == 1) {
  185. uni.navigateTo({ url: `../app-webview/app-webview?url=${this.swiper[index].url}` })
  186. }
  187. },
  188. indexRequest() { // 请求首页数据
  189. _API_IndexIndex().then(res => {
  190. uni.stopPullDownRefresh()
  191. this.news = res.data.news
  192. this.swiper = res.data.swiper
  193. })
  194. }
  195. }
  196. }
  197. </script>
  198. <style lang="scss" scoped>
  199. .index-index {
  200. @include page();
  201. .title {
  202. .cuIcon-question {
  203. font-size: 38rpx;
  204. margin-right: 30rpx;
  205. }
  206. }
  207. .content {
  208. .area {
  209. background: #FFFFFF;
  210. &.manage {
  211. height: 170rpx;
  212. display: flex;
  213. navigator {
  214. flex: 1;
  215. height: 100%;
  216. display: flex;
  217. align-items: center;
  218. flex-direction: column;
  219. image {
  220. width: 94rpx;
  221. height: 94rpx;
  222. margin-top: 20rpx;
  223. }
  224. text {
  225. font-size:32rpx;
  226. margin-top: 10rpx;
  227. }
  228. }
  229. }
  230. &.swiper {
  231. height: 250rpx;
  232. margin-top: 12rpx;
  233. swiper {
  234. height: 100%;
  235. image {
  236. width: 100%;
  237. height: 100%;
  238. }
  239. }
  240. }
  241. &.news {
  242. display: flex;
  243. height: 50rpx;
  244. padding: 10rpx 30rpx;
  245. box-sizing: border-box;
  246. image {
  247. height: 100%;
  248. width: 180rpx;
  249. }
  250. .hot {
  251. @include flex();
  252. width: 72rpx;
  253. height: 100%;
  254. font-size: 24rpx;
  255. margin-left: 10rpx;
  256. border-radius: 4rpx;
  257. color: $app-base-color;
  258. border:1px solid $app-base-color;
  259. }
  260. swiper {
  261. flex: 1;
  262. height: 100%;
  263. font-size: 26rpx;
  264. margin-left: 20rpx;
  265. }
  266. }
  267. &.article {
  268. margin-top: 10rpx;
  269. .area-name {
  270. @include flex();
  271. height: 72rpx;
  272. font-size: 32rpx;
  273. padding: 0 30rpx;
  274. box-sizing: border-box;
  275. justify-content: flex-start;
  276. border-bottom: 1rpx solid $app-base-bg;
  277. .border {
  278. width: 6rpx;
  279. height: 30rpx;
  280. margin-right: 16rpx;
  281. background: $app-base-color;
  282. }
  283. }
  284. .article-body {
  285. @include flex();
  286. height: 200rpx;
  287. padding: 10rpx 30rpx;
  288. box-sizing: border-box;
  289. .left {
  290. width: 180rpx;
  291. height: 180rpx;
  292. margin-right: 30rpx;
  293. border-radius: 10rpx;
  294. }
  295. .right {
  296. @include flex(column);
  297. flex: 1;
  298. height: 100%;
  299. align-items: flex-start;
  300. justify-content: space-between;
  301. .title {
  302. width: 444rpx;
  303. font-size: 32rpx;
  304. }
  305. .des {
  306. flex: 1;
  307. width: 100%;
  308. margin: 2rpx 0;
  309. font-size: 24rpx;
  310. overflow: scroll;
  311. }
  312. .time-auth {
  313. @include flex();
  314. width: 100%;
  315. font-size: 24rpx;
  316. color: $app-sec-text-color;
  317. justify-content: space-between;
  318. }
  319. }
  320. }
  321. .more-article {
  322. @include flex();
  323. height: 72rpx;
  324. font-size: 26rpx;
  325. border-top: 1rpx solid $app-base-bg;
  326. }
  327. }
  328. }
  329. }
  330. }
  331. </style>