index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  1. <template>
  2. <view style="background-color: #FFFFFF;height: 100vh;" class="u-skeleton">
  3. <view class="status_bar">
  4. <!-- 这里是状态栏 -->
  5. </view>
  6. <view class="u-page" style="margin-bottom: 30rpx;">
  7. <view class="u-m-t-35">
  8. <u-swiper :list="bannersList" :height="310" :effect3d="true" border-radius="20" effect3d-previous-margin="20"
  9. bg-color="#FFF" class="u-skeleton-fillet" v-if="bannersList.length!=0"></u-swiper>
  10. <u-swiper :list="package[langIndex].swiper" :height="310" :effect3d="true" border-radius="20" effect3d-previous-margin="20" bg-color="#FFF"
  11. class="u-skeleton-fillet" v-else></u-swiper>
  12. </view>
  13. <view class="u-flex u-m-t-35 u-m-l-20 u-m-r-20 u-skeleton-fillet" style="width:710rpx;">
  14. <u-notice-bar mode="vertical" :list="noticebarList" style="width: 710rpx;" type="primary"></u-notice-bar>
  15. </view>
  16. <!-- <view class="u-flex u-m-t-35 u-row-around u-m-l-10 u-m-r-10">
  17. <u-image width="350rpx" src="../../static/sailun/scan_in.png" @tap="$u.throttle(inPage(0), 1000)" mode="widthFix"
  18. class="u-skeleton-fillet"></u-image>
  19. <u-image width="350rpx" src="../../static/sailun/scan_out.png" @tap="$u.throttle(inPage(1), 1000)" mode="widthFix"
  20. class="u-skeleton-fillet"></u-image>
  21. </view> -->
  22. <view class="u-flex u-m-t-35 u-row-around u-m-l-10 u-m-r-10">
  23. <template v-for="(item, index) in package[langIndex].banner">
  24. <u-image width="350rpx" :src="item.img" @tap="$u.throttle(routerPage(item.url), 1000)" mode="widthFix"
  25. class="u-skeleton-fillet"></u-image>
  26. </template>
  27. </view>
  28. <view class="u-m-t-35">
  29. <view class="u-m-l-30 u-m-b-10" style="font-size: 34rpx;">
  30. {{ $t('index.quickService') }}
  31. </view>
  32. <!-- <view class="u-flex u-flex-wrap u-row-center">
  33. <u-image class="u-skeleton-fillet" width="350rpx" height="212rpx" src="../../static/sailun/task.png" style="margin:10rpx 10rpx 25rpx 10rpx;box-shadow:0rpx 0rpx 20rpx rgba(0,0,0,0.2);border-radius: 30rpx;"
  34. @click="inPage(5)"></u-image>
  35. <u-image class="u-skeleton-fillet" width="350rpx" height="212rpx" src="../../static/sailun/2.png" style="margin: 10rpx 10rpx 25rpx 10rpx;box-shadow:0rpx 0rpx 20rpx rgba(0,0,0,0.2);border-radius: 30rpx;"
  36. @click="inPage(3)"></u-image>
  37. <u-image class="u-skeleton-fillet" width="350rpx" height="212rpx" src="../../static/sailun/inquire.png" style="margin: 10rpx;box-shadow:0rpx 0rpx 20rpx rgba(0,0,0,0.2);border-radius: 30rpx;"
  38. @click="inPage(4)"></u-image>
  39. <u-image class="u-skeleton-fillet" width="350rpx" height="212rpx" src="../../static/sailun/1.png" style="margin: 10rpx;box-shadow:0rpx 0rpx 20rpx rgba(0,0,0,0.2);border-radius: 30rpx;"
  40. @click="inPage(2)"></u-image>
  41. </view> -->
  42. <view class="u-flex u-flex-wrap u-row-center">
  43. <template v-for="(item, index) in package[langIndex].service">
  44. <u-image class="u-skeleton-fillet" width="350rpx" height="212rpx" :src="item.img" style="margin:10rpx 10rpx 25rpx 10rpx;box-shadow:0rpx 0rpx 20rpx rgba(0,0,0,0.2);border-radius: 30rpx;"
  45. @click="routerPage(item.url)"></u-image>
  46. </template>
  47. </view>
  48. </view>
  49. <view class="u-flex u-row-center u-m-t-35">
  50. <template v-for="(item, index) in package[langIndex].ad">
  51. <u-image class="u-skeleton-fillet" width="680rpx" :src="item" mode="widthFix"></u-image>
  52. </template>
  53. </view>
  54. </view>
  55. <!-- 与包裹页面所有内容的元素u-page同级,且在它的下方 -->
  56. <!-- <u-tabbar v-model="current" :list="list"></u-tabbar> -->
  57. <u-skeleton :loading="loading" :animation="true"></u-skeleton>
  58. <u-toast ref="ulogin" />
  59. <luo-version-upgrade v-if="show_s == true" :version="platform" :url="url" :is_force="is_force" :describe="Copywriting"></luo-version-upgrade>
  60. </view>
  61. </template>
  62. <script>
  63. import versionUpgrade from "../../components/luo-version-upgrade/luo-version-upgrade.vue";
  64. import {
  65. mapState,
  66. mapMutations
  67. } from 'vuex'
  68. import {
  69. request
  70. } from '../../common/request/request'
  71. require("promise.prototype.finally").shim()
  72. import axios from 'axios'
  73. export default {
  74. components: {
  75. versionUpgrade
  76. },
  77. data() {
  78. return {
  79. bannersList: [],
  80. noticebarList: [],
  81. loading: true, // 是否显示骨架屏组件
  82. list: [
  83. '../../static/sailun/swiper1.png'
  84. ],
  85. show_s: false,
  86. url: '',
  87. is_force: false,
  88. Copywriting: '',
  89. platform:'',
  90. langIndex: 0,
  91. package: [{
  92. swiper: [
  93. '../../static/sailun/swiper1.png',
  94. '../../static/sailun/swiper1.png'
  95. ],
  96. banner: [
  97. {
  98. img: '../../static/sailun/scan_in.png',
  99. url: 'pages/home/scancode/index'
  100. },
  101. {
  102. img: '../../static/sailun/scan_out.png',
  103. url: 'pages/home/scancode/scancodeout'
  104. }
  105. ],
  106. service: [
  107. {
  108. img: '../../static/sailun/task.png',
  109. url: 'pages/home/Statistical-task/index',
  110. },
  111. {
  112. img: '../../static/sailun/2.png',
  113. url: 'pages/home/monthly-policy/monthly-policy'
  114. },
  115. {
  116. img: '../../static/sailun/inquire.png',
  117. url: 'pages/home/scancodequery/result'
  118. },
  119. {
  120. img: '../../static/sailun/1.png',
  121. url: 'pages/home/my-stock/my-stock'
  122. }
  123. ],
  124. ad:[
  125. '../../static/sailun/88reward.png'
  126. ]
  127. }, {
  128. swiper: [
  129. '../../static/sailun/swiper1.png'
  130. ],
  131. banner: [
  132. {
  133. img: '../../static/sailun/scan_out.png',
  134. url: 'pages/home/scancode/scancodeout'
  135. },
  136. {
  137. img: '../../static/sailun/scan_in.png',
  138. url: 'pages/home/scancode/index'
  139. }
  140. ],
  141. service: [
  142. {
  143. img: '../../static/sailun/inquire.png',
  144. url: 'pages/home/scancodequery/result'
  145. },
  146. {
  147. img: '../../static/sailun/1.png',
  148. url: 'pages/home/my-stock/my-stock'
  149. },
  150. {
  151. img: '../../static/sailun/task.png',
  152. url: 'pages/home/Statistical-task/index',
  153. },
  154. {
  155. img: '../../static/sailun/2.png',
  156. url: 'pages/home/monthly-policy/monthly-policy'
  157. }
  158. ],
  159. ad:[
  160. '../../static/sailun/88reward.png'
  161. ]
  162. }]
  163. }
  164. },
  165. onLoad() {
  166. uni.$on('login', (data) => {
  167. this.loginStatus = data.msg
  168. })
  169. // uni.startPullDownRefresh();
  170. },
  171. onReady() {
  172. if (this.loginStatus == "登录成功" || this.loginStatus == "login sucess") {
  173. this.$refs.ulogin.show({
  174. title: this.$t('index.loginSuc'),
  175. })
  176. }
  177. },
  178. created() {
  179. if (this.hasLogin) {
  180. uni.showLoading({
  181. title: this.$t('unified.Loading')
  182. });
  183. axios.all([this.getBanners(), this.getTiceList()])
  184. .then(axios.spread((one, two) => {
  185. this.bannersList = one.data.data.map(t => t.imgPath)
  186. // console.log(one)
  187. this.noticebarList = two.data.data.map(t => t.msgContent)
  188. }))
  189. .catch(err => {
  190. })
  191. .finally(() => {
  192. this.loading = false;
  193. uni.hideLoading();
  194. })
  195. let lang = localStorage.getItem('lang')
  196. if (lang === 'zh') {
  197. console.log('当前为中文')
  198. this.langIndex = 0
  199. } else if (lang === 'en') {
  200. console.log('当前为英文')
  201. this.langIndex = 1
  202. } else {
  203. this.langIndex = 0
  204. }
  205. uni.setTabBarItem({
  206. index: 0,
  207. text: this.$t('tabBar.index')
  208. })
  209. uni.setTabBarItem({
  210. index: 1,
  211. text: this.$t('tabBar.msg')
  212. })
  213. uni.setTabBarItem({
  214. index: 2,
  215. text: this.$t('tabBar.my')
  216. })
  217. }
  218. },
  219. onShow() {
  220. this.system()
  221. },
  222. onPullDownRefresh() {
  223. axios.all([this.getBanners(), this.getTiceList()])
  224. .then(axios.spread((one, two) => {
  225. this.bannersList = one.data.data.map(t => t.imgPath)
  226. this.noticebarList = two.data.data.map(t => t.msgContent)
  227. }))
  228. .catch(err => {
  229. })
  230. .finally(() => {
  231. this.loading = false;
  232. uni.stopPullDownRefresh();
  233. })
  234. },
  235. computed: {
  236. ...mapState(['hasLogin'])
  237. },
  238. methods: {
  239. system() {
  240. uni.getSystemInfo({
  241. success: res => {
  242. this.platform = res.platform
  243. },
  244. complete: err => {
  245. this.platform = err.platform
  246. if (err.platform == 'android') {
  247. this.onLaunch_s()
  248. } else if (err.platform == 'ios') {
  249. //
  250. this.iosstartup()
  251. }
  252. }
  253. });
  254. },
  255. iosstartup() {
  256. request({
  257. url: '/baseReq/apkUpgrade',
  258. method: 'get',
  259. params: {
  260. osType: 1
  261. }
  262. }).then(res => {
  263. plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
  264. //
  265. //版本号
  266. if (wgtinfo.version == res.data.version) {
  267. this.show_s = true
  268. // uni.showToast({
  269. // icon: 'none',
  270. // title: '已是最新版本',
  271. // position: "bottom"
  272. // })
  273. //
  274. } else if (wgtinfo.version != res.data.forceVersion) {
  275. //
  276. res.data.msg = res.data.msg.replace(/\\n/g, "\n")
  277. uni.showModal({
  278. title: this.$t('index.tip1'),
  279. content: res.data.msg,
  280. showCancel: false,
  281. confirmText: this.$t('index.tip2'),
  282. success: function(res) {
  283. if (res.confirm) {
  284. //
  285. let appleId = 1518555723
  286. plus.runtime.launchApplication({
  287. action: `itms-apps://itunes.apple.com/cn/app/id${appleId}?mt=8`
  288. }, function(e) {
  289. });
  290. } else if (res.cancel) {
  291. }
  292. }
  293. })
  294. } else if (wgtinfo.version == res.data.forceVersion) {
  295. res.data.msg = res.data.msg.replace(/\\n/g, "\n")
  296. uni.showModal({
  297. title: this.$t('index.tip1'),
  298. content: res.data.msg,
  299. showCancel: true,
  300. confirmText: this.$t('index.tip2'),
  301. success: function(res) {
  302. if (res.confirm) {
  303. let appleId = 1518555723
  304. plus.runtime.launchApplication({
  305. action: `itms-apps://itunes.apple.com/cn/app/id${appleId}?mt=8`
  306. }, function(e) {
  307. });
  308. } else if (res.cancel) {
  309. }
  310. }
  311. })
  312. }
  313. })
  314. }).catch(err => {
  315. })
  316. .finally(() => {
  317. // Loading.close()
  318. })
  319. },
  320. //升级调用的接口
  321. onLaunch_s() {
  322. request({
  323. url: '/baseReq/apkUpgrade',
  324. method: 'get',
  325. params: {
  326. osType: 0
  327. }
  328. }).then(res =>{
  329. plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
  330. if (wgtinfo.version == res.data.version) {
  331. this.show_s = false
  332. // uni.showToast({
  333. // icon: 'none',
  334. // title: '已是最新版本',
  335. // position: "bottom"
  336. // })
  337. } else if (wgtinfo.version != res.data.forceVersion) {
  338. this.Copywriting = res.data.msg
  339. this.show_s = true
  340. this.url = res.data.url
  341. this.is_force = true
  342. } else if (wgtinfo.version == res.data.forceVersion) {
  343. this.Copywriting = res.data.msg
  344. this.is_force = false
  345. this.show_s = true
  346. this.url = res.data.url
  347. }
  348. })
  349. }).catch(err => {
  350. })
  351. .finally(() => {
  352. // Loading.close()
  353. })
  354. },
  355. //轮播图
  356. getBanners() {
  357. return request({
  358. url: '/homepage/getBanners',
  359. method: 'post',
  360. data: {
  361. "storeId": this.$store.state.storeInfo.storeId,
  362. "showPosition": 0, //门店0
  363. }
  364. })
  365. },
  366. //消息文字跑马灯
  367. getTiceList() {
  368. return request({
  369. url: '/homepage/noticeList',
  370. method: 'post',
  371. data: {
  372. "storeId": this.$store.state.storeInfo.storeId,
  373. "contentType": "1" //门店1
  374. }
  375. })
  376. },
  377. // 当前跳转路由
  378. routerPage(url) {
  379. this.$u.route({
  380. url: url,
  381. })
  382. },
  383. inPage(index) {
  384. switch (index) {
  385. case 0:
  386. {
  387. this.$u.route({
  388. url: 'pages/home/scancode/index',
  389. })
  390. break;
  391. }
  392. case 1:
  393. {
  394. this.$u.route({
  395. url: 'pages/home/scancode/scancodeout',
  396. })
  397. break;
  398. }
  399. case 2:
  400. {
  401. this.$u.route({
  402. url: 'pages/home/my-stock/my-stock',
  403. })
  404. break;
  405. }
  406. case 3:
  407. {
  408. this.$u.route({
  409. url: 'pages/home/monthly-policy/monthly-policy',
  410. })
  411. break;
  412. }
  413. case 4:
  414. {
  415. this.$u.route({
  416. url: 'pages/home/scancodequery/result',
  417. })
  418. break;
  419. }
  420. case 5:
  421. {
  422. this.$u.route({
  423. url: 'pages/home/Statistical-task/index',
  424. })
  425. break;
  426. }
  427. }
  428. },
  429. },
  430. }
  431. </script>
  432. <style lang="scss" scoped>
  433. .status_bar {
  434. height: var(--status-bar-height);
  435. width: 100%;
  436. background-color: #FFF;
  437. }
  438. </style>