index.vue 9.2 KB

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