index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  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. 快捷服务
  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 == "登录成功") {
  173. this.$refs.ulogin.show({
  174. title: "登录成功",
  175. })
  176. }
  177. },
  178. created() {
  179. if (this.hasLogin) {
  180. uni.showLoading({
  181. title: '加载中...'
  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. }
  206. },
  207. onShow() {
  208. this.system()
  209. },
  210. onPullDownRefresh() {
  211. axios.all([this.getBanners(), this.getTiceList()])
  212. .then(axios.spread((one, two) => {
  213. this.bannersList = one.data.data.map(t => t.imgPath)
  214. this.noticebarList = two.data.data.map(t => t.msgContent)
  215. }))
  216. .catch(err => {
  217. })
  218. .finally(() => {
  219. this.loading = false;
  220. uni.stopPullDownRefresh();
  221. })
  222. },
  223. computed: {
  224. ...mapState(['hasLogin'])
  225. },
  226. methods: {
  227. system() {
  228. uni.getSystemInfo({
  229. success: res => {
  230. this.platform = res.platform
  231. },
  232. complete: err => {
  233. this.platform = err.platform
  234. if (err.platform == 'android') {
  235. this.onLaunch_s()
  236. } else if (err.platform == 'ios') {
  237. //
  238. this.iosstartup()
  239. }
  240. }
  241. });
  242. },
  243. iosstartup() {
  244. request({
  245. url: '/baseReq/apkUpgrade',
  246. method: 'get',
  247. params: {
  248. osType: 1
  249. }
  250. }).then(res => {
  251. plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
  252. //
  253. //版本号
  254. if (wgtinfo.version == res.data.version) {
  255. this.show_s = true
  256. // uni.showToast({
  257. // icon: 'none',
  258. // title: '已是最新版本',
  259. // position: "bottom"
  260. // })
  261. //
  262. } else if (wgtinfo.version != res.data.forceVersion) {
  263. //
  264. res.data.msg = res.data.msg.replace(/\\n/g, "\n")
  265. uni.showModal({
  266. title: "发现新版本",
  267. content: res.data.msg,
  268. showCancel: false,
  269. confirmText: "立即去AppStore更新",
  270. success: function(res) {
  271. if (res.confirm) {
  272. //
  273. let appleId = 1518555723
  274. plus.runtime.launchApplication({
  275. action: `itms-apps://itunes.apple.com/cn/app/id${appleId}?mt=8`
  276. }, function(e) {
  277. });
  278. } else if (res.cancel) {
  279. }
  280. }
  281. })
  282. } else if (wgtinfo.version == res.data.forceVersion) {
  283. res.data.msg = res.data.msg.replace(/\\n/g, "\n")
  284. uni.showModal({
  285. title: "发现新版本",
  286. content: res.data.msg,
  287. showCancel: true,
  288. confirmText: "立即去AppStore更新",
  289. success: function(res) {
  290. if (res.confirm) {
  291. let appleId = 1518555723
  292. plus.runtime.launchApplication({
  293. action: `itms-apps://itunes.apple.com/cn/app/id${appleId}?mt=8`
  294. }, function(e) {
  295. });
  296. } else if (res.cancel) {
  297. }
  298. }
  299. })
  300. }
  301. })
  302. }).catch(err => {
  303. })
  304. .finally(() => {
  305. // Loading.close()
  306. })
  307. },
  308. //升级调用的接口
  309. onLaunch_s() {
  310. request({
  311. url: '/baseReq/apkUpgrade',
  312. method: 'get',
  313. params: {
  314. osType: 0
  315. }
  316. }).then(res =>{
  317. plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
  318. if (wgtinfo.version == res.data.version) {
  319. this.show_s = false
  320. // uni.showToast({
  321. // icon: 'none',
  322. // title: '已是最新版本',
  323. // position: "bottom"
  324. // })
  325. } else if (wgtinfo.version != res.data.forceVersion) {
  326. this.Copywriting = res.data.msg
  327. this.show_s = true
  328. this.url = res.data.url
  329. this.is_force = true
  330. } else if (wgtinfo.version == res.data.forceVersion) {
  331. this.Copywriting = res.data.msg
  332. this.is_force = false
  333. this.show_s = true
  334. this.url = res.data.url
  335. }
  336. })
  337. }).catch(err => {
  338. })
  339. .finally(() => {
  340. // Loading.close()
  341. })
  342. },
  343. //轮播图
  344. getBanners() {
  345. return request({
  346. url: '/homepage/getBanners',
  347. method: 'post',
  348. data: {
  349. "storeId": this.$store.state.storeInfo.storeId,
  350. "showPosition": 0, //门店0
  351. }
  352. })
  353. },
  354. //消息文字跑马灯
  355. getTiceList() {
  356. return request({
  357. url: '/homepage/noticeList',
  358. method: 'post',
  359. data: {
  360. "storeId": this.$store.state.storeInfo.storeId,
  361. "contentType": "1" //门店1
  362. }
  363. })
  364. },
  365. // 当前跳转路由
  366. routerPage(url) {
  367. this.$u.route({
  368. url: url,
  369. })
  370. },
  371. inPage(index) {
  372. switch (index) {
  373. case 0:
  374. {
  375. this.$u.route({
  376. url: 'pages/home/scancode/index',
  377. })
  378. break;
  379. }
  380. case 1:
  381. {
  382. this.$u.route({
  383. url: 'pages/home/scancode/scancodeout',
  384. })
  385. break;
  386. }
  387. case 2:
  388. {
  389. this.$u.route({
  390. url: 'pages/home/my-stock/my-stock',
  391. })
  392. break;
  393. }
  394. case 3:
  395. {
  396. this.$u.route({
  397. url: 'pages/home/monthly-policy/monthly-policy',
  398. })
  399. break;
  400. }
  401. case 4:
  402. {
  403. this.$u.route({
  404. url: 'pages/home/scancodequery/result',
  405. })
  406. break;
  407. }
  408. case 5:
  409. {
  410. this.$u.route({
  411. url: 'pages/home/Statistical-task/index',
  412. })
  413. break;
  414. }
  415. }
  416. },
  417. },
  418. }
  419. </script>
  420. <style lang="scss" scoped>
  421. .status_bar {
  422. height: var(--status-bar-height);
  423. width: 100%;
  424. background-color: #FFF;
  425. }
  426. </style>