index.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358
  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. // uni.startPullDownRefresh();
  85. },
  86. onReady() {
  87. if (this.loginStatus == "登录成功") {
  88. this.$refs.ulogin.show({
  89. title: "登录成功",
  90. })
  91. }
  92. },
  93. created() {
  94. if (this.hasLogin) {
  95. uni.showLoading({
  96. title: '加载中...'
  97. });
  98. axios.all([this.getBanners(), this.getTiceList()])
  99. .then(axios.spread((one, two) => {
  100. this.bannersList = one.data.data.map(t => t.imgPath)
  101. console.log(one)
  102. this.noticebarList = two.data.data.map(t => t.msgContent)
  103. }))
  104. .catch(err => {
  105. })
  106. .finally(() => {
  107. this.loading = false;
  108. uni.hideLoading();
  109. })
  110. }
  111. },
  112. onShow() {
  113. this.system()
  114. },
  115. onPullDownRefresh() {
  116. axios.all([this.getBanners(), this.getTiceList()])
  117. .then(axios.spread((one, two) => {
  118. this.bannersList = one.data.data.map(t => t.imgPath)
  119. this.noticebarList = two.data.data.map(t => t.msgContent)
  120. }))
  121. .catch(err => {
  122. })
  123. .finally(() => {
  124. this.loading = false;
  125. uni.stopPullDownRefresh();
  126. })
  127. // setTimeout(function() {
  128. // }, 1000);
  129. },
  130. computed: {
  131. ...mapState(['hasLogin'])
  132. },
  133. methods: {
  134. system() {
  135. uni.getSystemInfo({
  136. success: res => {
  137. //
  138. },
  139. complete: err => {
  140. if (err.platform == 'android') {
  141. this.onLaunch_s()
  142. } else if (err.platform == 'ios') {
  143. //
  144. this.iosstartup()
  145. }
  146. }
  147. });
  148. },
  149. iosstartup() {
  150. request({
  151. url: '/baseReq/apkUpgrade',
  152. method: 'get',
  153. params: {
  154. osType: 1
  155. }
  156. }).then(res => {
  157. //
  158. //
  159. // //最低版本
  160. // //更新文案
  161. // //最新版本
  162. plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
  163. //
  164. //版本号
  165. if (wgtinfo.version == res.data.version) {
  166. this.show_s = true
  167. // uni.showToast({
  168. // icon: 'none',
  169. // title: '已是最新版本',
  170. // position: "bottom"
  171. // })
  172. //
  173. } else if (wgtinfo.version != res.data.forceVersion) {
  174. //
  175. res.data.msg = res.data.msg.replace(/\\n/g, "\n")
  176. uni.showModal({
  177. title: "发现新版本",
  178. content: res.data.msg,
  179. showCancel: false,
  180. confirmText: "立即去AppStore更新",
  181. success: function(res) {
  182. if (res.confirm) {
  183. //
  184. let appleId = 1518555723
  185. plus.runtime.launchApplication({
  186. action: `itms-apps://itunes.apple.com/cn/app/id${appleId}?mt=8`
  187. }, function(e) {
  188. });
  189. } else if (res.cancel) {
  190. }
  191. }
  192. })
  193. } else if (wgtinfo.version == res.data.forceVersion) {
  194. res.data.msg = res.data.msg.replace(/\\n/g, "\n")
  195. uni.showModal({
  196. title: "发现新版本",
  197. content: res.data.msg,
  198. showCancel: true,
  199. confirmText: "立即去AppStore更新",
  200. success: function(res) {
  201. if (res.confirm) {
  202. let appleId = 1518555723
  203. plus.runtime.launchApplication({
  204. action: `itms-apps://itunes.apple.com/cn/app/id${appleId}?mt=8`
  205. }, function(e) {
  206. });
  207. } else if (res.cancel) {
  208. }
  209. }
  210. })
  211. }
  212. })
  213. }).catch(err => {
  214. })
  215. .finally(() => {
  216. // Loading.close()
  217. })
  218. },
  219. //升级调用的接口
  220. onLaunch_s() {
  221. request({
  222. url: '/baseReq/apkUpgrade',
  223. method: 'get',
  224. params: {
  225. osType: 0
  226. }
  227. }).then(res => {
  228. //最低版本
  229. //更新文案
  230. //下载最新版地址
  231. //最新版本
  232. plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
  233. //版本号
  234. if (wgtinfo.version == res.data.version) {
  235. this.show_s = false
  236. // uni.showToast({
  237. // icon: 'none',
  238. // title: '已是最新版本',
  239. // position: "bottom"
  240. // })
  241. } else if (wgtinfo.version != res.data.forceVersion) {
  242. this.Copywriting = res.data.msg
  243. this.show_s = true
  244. this.url = res.data.url
  245. this.is_force = true
  246. } else if (wgtinfo.version == res.data.forceVersion) {
  247. this.Copywriting = res.data.msg
  248. this.is_force = false
  249. this.show_s = true
  250. this.url = res.data.url
  251. }
  252. })
  253. }).catch(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. },
  328. }
  329. </script>
  330. <style lang="scss" scoped>
  331. .status_bar {
  332. height: var(--status-bar-height);
  333. width: 100%;
  334. background-color: #FFF;
  335. }
  336. </style>