index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  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: 20rpx;">
  7. <view class="u-m-t-20">
  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="list" :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-20 u-m-l-20 u-m-r-20 u-skeleton-fillet" style="width:710rpx;">
  14. <!-- <view class="u-flex u-row-center" style="width: 150rpx; height: 70rpx;border-radius: 50rpx;background: rgba(52,140,245,0.1);font-size: 20rpx;color: #348CF5; font-size: 500;">
  15. <u-image width="45rpx" height="35rpx" src="../../static/sailun/speaker.png" style="margin:10rpx;"></u-image>公告
  16. <u-notice-bar mode="horizontal" :list="noticebarList" :volume-icon="false" bg-color="#FFF" color="#2B2B2B" padding="18rpx 12rpx" :is-circular="false"></u-notice-bar> -->
  17. <u-notice-bar mode="vertical" :list="noticebarList" style="width: 710rpx;" type="primary"></u-notice-bar>
  18. </view>
  19. <view class="u-flex u-m-t-20 u-row-around u-m-l-10 u-m-r-10">
  20. <u-image width="350rpx" src="../../static/sailun/scan_in.png" @tap="$u.throttle(inPage(0), 1000)" mode="widthFix"
  21. class="u-skeleton-fillet"></u-image>
  22. <u-image width="350rpx" src="../../static/sailun/scan_out.png" @tap="$u.throttle(inPage(1), 1000)" mode="widthFix"
  23. class="u-skeleton-fillet"></u-image>
  24. </view>
  25. <view class="u-m-t-20">
  26. <view class="u-m-l-30" style="font-size: 34rpx;">
  27. 快捷服务
  28. </view>
  29. <view class="u-flex u-flex-wrap u-row-center">
  30. <u-image class="u-skeleton-fillet" width="350rpx" height="212rpx" src="../../static/sailun/task.png" style="margin: 10rpx;box-shadow:0rpx 0rpx 20rpx rgba(0,0,0,0.2);border-radius: 30rpx;"
  31. @click="inPage(5)"></u-image>
  32. <u-image class="u-skeleton-fillet" width="350rpx" height="212rpx" src="../../static/sailun/2.png" style="margin: 10rpx;box-shadow:0rpx 0rpx 20rpx rgba(0,0,0,0.2);border-radius: 30rpx;"
  33. @click="inPage(3)"></u-image>
  34. <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;"
  35. @click="inPage(4)"></u-image>
  36. <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;"
  37. @click="inPage(2)"></u-image>
  38. </view>
  39. </view>
  40. <view class="u-flex u-row-center u-m-t-30">
  41. <u-image class="u-skeleton-fillet" width="680rpx" src="../../static/sailun/88reward.png" mode="widthFix"></u-image>
  42. </view>
  43. </view>
  44. <!-- 与包裹页面所有内容的元素u-page同级,且在它的下方 -->
  45. <!-- <u-tabbar v-model="current" :list="list"></u-tabbar> -->
  46. <u-skeleton :loading="loading" :animation="true"></u-skeleton>
  47. <u-toast ref="ulogin" />
  48. <luo-version-upgrade v-if="show_s == true" version="1.0.1" :url="url" :is_force="is_force" :describe="Copywriting"></luo-version-upgrade>
  49. </view>
  50. </template>
  51. <script>
  52. import versionUpgrade from "../../components/luo-version-upgrade/luo-version-upgrade.vue";
  53. import {
  54. mapState,
  55. mapMutations
  56. } from 'vuex'
  57. import {
  58. request
  59. } from '../../common/request/request'
  60. require("promise.prototype.finally").shim()
  61. import axios from 'axios'
  62. export default {
  63. components: {
  64. versionUpgrade
  65. },
  66. data() {
  67. return {
  68. bannersList: [],
  69. noticebarList: [],
  70. loading: true, // 是否显示骨架屏组件
  71. list: [
  72. '../../static/sailun/swiper1.png'
  73. ],
  74. show_s: false,
  75. url: '',
  76. is_force: false,
  77. Copywriting: '',
  78. }
  79. },
  80. onLoad() {
  81. uni.$on('login', (data) => {
  82. this.loginStatus = data.msg
  83. })
  84. },
  85. onReady() {
  86. if (this.loginStatus == "登录成功") {
  87. this.$refs.ulogin.show({
  88. title: "登录成功",
  89. })
  90. }
  91. },
  92. created() {
  93. if (this.hasLogin) {
  94. uni.showLoading({
  95. title: '加载中...'
  96. });
  97. axios.all([this.getBanners(), this.getTiceList()])
  98. .then(axios.spread((one, two) => {
  99. this.bannersList = one.data.data.map(t => t.imgPath)
  100. this.noticebarList = two.data.data.map(t => t.msgContent)
  101. }))
  102. .catch(err => {
  103. console.log(err)
  104. })
  105. .finally(() => {
  106. this.loading = false;
  107. uni.hideLoading();
  108. })
  109. }
  110. },
  111. onShow() {
  112. this.system()
  113. },
  114. computed: {
  115. ...mapState(['hasLogin'])
  116. },
  117. methods: {
  118. system() {
  119. uni.getSystemInfo({
  120. success: res => {
  121. // console.log(res.platform);
  122. },
  123. complete: err => {
  124. if (err.platform == 'android') {
  125. this.onLaunch_s()
  126. } else if (err.platform == 'ios') {
  127. // console.log("暂无数据")
  128. this.iosstartup()
  129. }
  130. }
  131. });
  132. },
  133. iosstartup() {
  134. request({
  135. url: '/baseReq/apkUpgrade',
  136. method: 'get',
  137. params: {
  138. osType: 1
  139. }
  140. }).then(res => {
  141. // console.log(res)
  142. // console.log(res.data.code)
  143. // console.log(res.data.forceVersion) //最低版本
  144. // console.log(res.data.msg) //更新文案
  145. // console.log(res.data.version) //最新版本
  146. plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
  147. // console.log(wgtinfo);
  148. console.log(wgtinfo.version); //版本号
  149. if (wgtinfo.version == res.data.version) {
  150. this.show_s = true
  151. // uni.showToast({
  152. // icon: 'none',
  153. // title: '已是最新版本',
  154. // position: "bottom"
  155. // })
  156. // console.log("已是最新版本")
  157. } else if (wgtinfo.version != res.data.forceVersion) {
  158. // console.log("强制版本更新"+res)
  159. res.data.msg = res.data.msg.replace(/\\n/g, "\n")
  160. uni.showModal({
  161. title: "发现新版本",
  162. content: res.data.msg,
  163. showCancel: false,
  164. confirmText: "立即去AppStore更新",
  165. success: function(res) {
  166. if (res.confirm) {
  167. // console.log('用户点击确定');
  168. let appleId = 1518555723
  169. plus.runtime.launchApplication({
  170. action: `itms-apps://itunes.apple.com/cn/app/id${appleId}?mt=8`
  171. }, function(e) {
  172. console.log('Open system default browser failed: ' + e.message);
  173. });
  174. } else if (res.cancel) {
  175. console.log('用户点击取消');
  176. }
  177. }
  178. })
  179. } else if (wgtinfo.version == res.data.forceVersion) {
  180. console.log("最低版本更新")
  181. res.data.msg = res.data.msg.replace(/\\n/g, "\n")
  182. uni.showModal({
  183. title: "发现新版本",
  184. content: res.data.msg,
  185. showCancel: true,
  186. confirmText: "立即去AppStore更新",
  187. success: function(res) {
  188. if (res.confirm) {
  189. console.log('用户点击确定');
  190. let appleId = 1518555723
  191. plus.runtime.launchApplication({
  192. action: `itms-apps://itunes.apple.com/cn/app/id${appleId}?mt=8`
  193. }, function(e) {
  194. console.log('Open system default browser failed: ' + e.message);
  195. });
  196. } else if (res.cancel) {
  197. console.log('用户点击取消');
  198. }
  199. }
  200. })
  201. }
  202. })
  203. }).catch(err => {
  204. console.log(err)
  205. })
  206. .finally(() => {
  207. // Loading.close()
  208. })
  209. },
  210. //升级调用的接口
  211. onLaunch_s() {
  212. request({
  213. url: '/baseReq/apkUpgrade',
  214. method: 'get',
  215. params: {
  216. osType: 0
  217. }
  218. }).then(res => {
  219. // console.log(res.data.code)
  220. // console.log(res.data.forceVersion) //最低版本
  221. // console.log(res.data.msg) //更新文案
  222. // console.log(res.data.url) //下载最新版地址
  223. // console.log(res.data.version) //最新版本
  224. plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
  225. // console.log(wgtinfo);
  226. // console.log(wgtinfo.version); //版本号
  227. if (wgtinfo.version == res.data.version) {
  228. this.show_s = false
  229. // uni.showToast({
  230. // icon: 'none',
  231. // title: '已是最新版本',
  232. // position: "bottom"
  233. // })
  234. // console.log("已是最新版本")
  235. } else if (wgtinfo.version != res.data.forceVersion) {
  236. // console.log("必须强制更新")
  237. this.Copywriting = res.data.msg
  238. console.log(this.Copywriting)
  239. this.show_s = true
  240. console.log(res.data.url)
  241. this.url = res.data.url
  242. this.is_force = true
  243. } else if (wgtinfo.version == res.data.forceVersion) {
  244. console.log("达到最低版本")
  245. this.Copywriting = res.data.msg
  246. console.log(this.Copywriting)
  247. this.is_force = false
  248. this.show_s = true
  249. this.url = res.data.url
  250. }
  251. })
  252. }).catch(err => {
  253. console.log(err)
  254. })
  255. .finally(() => {
  256. // Loading.close()
  257. })
  258. },
  259. //轮播图
  260. getBanners() {
  261. return request({
  262. url: '/homepage/getBanners',
  263. method: 'post',
  264. data: {
  265. "storeId": this.$store.state.storeInfo.storeId,
  266. "showPosition": 0, //门店0
  267. }
  268. })
  269. },
  270. //消息文字跑马灯
  271. getTiceList() {
  272. return request({
  273. url: '/homepage/noticeList',
  274. method: 'post',
  275. data: {
  276. "storeId": this.$store.state.storeInfo.storeId,
  277. "contentType": "1" //门店1
  278. }
  279. })
  280. },
  281. inPage(index) {
  282. switch (index) {
  283. case 0:
  284. {
  285. this.$u.route({
  286. url: 'pages/home/scancode/index',
  287. })
  288. break;
  289. }
  290. case 1:
  291. {
  292. this.$u.route({
  293. url: 'pages/home/scancode/scancodeout',
  294. })
  295. break;
  296. }
  297. case 2:
  298. {
  299. this.$u.route({
  300. url: 'pages/home/my-stock/my-stock',
  301. })
  302. break;
  303. }
  304. case 3:
  305. {
  306. this.$u.route({
  307. url: 'pages/home/monthly-policy/monthly-policy',
  308. })
  309. break;
  310. }
  311. case 4:
  312. {
  313. this.$u.route({
  314. url: 'pages/home/scancodequery/result',
  315. })
  316. break;
  317. }
  318. case 5:
  319. {
  320. this.$u.route({
  321. url: 'pages/home/Statistical-task/index',
  322. })
  323. break;
  324. }
  325. }
  326. },
  327. inInlineshop() {
  328. this.$u.toast('线上订货暂不开放');
  329. // this.$u.route({
  330. // url: 'pages/home/inline-shop/inline_shop',
  331. // })
  332. },
  333. inIntegral() {
  334. this.$u.toast('积分商城暂不开放');
  335. // this.$u.route({
  336. // url: 'pages/home/integral-mall/integral_mall',
  337. // })
  338. }
  339. },
  340. }
  341. </script>
  342. <style lang="scss" scoped>
  343. .status_bar {
  344. height: var(--status-bar-height);
  345. width: 100%;
  346. background-color: #FFF;
  347. }
  348. </style>