index.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  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" :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. // let add = ''这个不要删除!
  133. // console.log(res)这个不要删除!
  134. },
  135. complete: err => {
  136. if (err.platform == 'android') {
  137. this.onLaunch_s()
  138. } else if (err.platform == 'ios') {
  139. //
  140. this.iosstartup()
  141. }
  142. }
  143. });
  144. },
  145. iosstartup() {
  146. request({
  147. url: '/baseReq/apkUpgrade',
  148. method: 'get',
  149. params: {
  150. osType: 1
  151. }
  152. }).then(res => {
  153. //
  154. //
  155. // //最低版本
  156. // //更新文案
  157. // //最新版本
  158. plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
  159. //
  160. //版本号
  161. if (wgtinfo.version == res.data.version) {
  162. this.show_s = true
  163. // uni.showToast({
  164. // icon: 'none',
  165. // title: '已是最新版本',
  166. // position: "bottom"
  167. // })
  168. //
  169. } else if (wgtinfo.version != res.data.forceVersion) {
  170. //
  171. res.data.msg = res.data.msg.replace(/\\n/g, "\n")
  172. uni.showModal({
  173. title: "发现新版本",
  174. content: res.data.msg,
  175. showCancel: false,
  176. confirmText: "立即去AppStore更新",
  177. success: function(res) {
  178. if (res.confirm) {
  179. //
  180. let appleId = 1518555723
  181. plus.runtime.launchApplication({
  182. action: `itms-apps://itunes.apple.com/cn/app/id${appleId}?mt=8`
  183. }, function(e) {
  184. });
  185. } else if (res.cancel) {
  186. }
  187. }
  188. })
  189. } else if (wgtinfo.version == res.data.forceVersion) {
  190. res.data.msg = res.data.msg.replace(/\\n/g, "\n")
  191. uni.showModal({
  192. title: "发现新版本",
  193. content: res.data.msg,
  194. showCancel: true,
  195. confirmText: "立即去AppStore更新",
  196. success: function(res) {
  197. if (res.confirm) {
  198. let appleId = 1518555723
  199. plus.runtime.launchApplication({
  200. action: `itms-apps://itunes.apple.com/cn/app/id${appleId}?mt=8`
  201. }, function(e) {
  202. });
  203. } else if (res.cancel) {
  204. }
  205. }
  206. })
  207. }
  208. })
  209. }).catch(err => {
  210. })
  211. .finally(() => {
  212. // Loading.close()
  213. })
  214. },
  215. //升级调用的接口
  216. onLaunch_s() {
  217. request({
  218. url: '/baseReq/apkUpgrade',
  219. method: 'get',
  220. params: {
  221. osType: 0
  222. }
  223. }).then(res => {
  224. //最低版本
  225. //更新文案
  226. //下载最新版地址
  227. //最新版本
  228. plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
  229. //版本号
  230. if (wgtinfo.version == res.data.version) {
  231. this.show_s = false
  232. // uni.showToast({
  233. // icon: 'none',
  234. // title: '已是最新版本',
  235. // position: "bottom"
  236. // })
  237. } else if (wgtinfo.version != res.data.forceVersion) {
  238. this.Copywriting = res.data.msg
  239. this.show_s = true
  240. this.url = res.data.url
  241. this.is_force = true
  242. } else if (wgtinfo.version == res.data.forceVersion) {
  243. this.Copywriting = res.data.msg
  244. this.is_force = false
  245. this.show_s = true
  246. this.url = res.data.url
  247. }
  248. })
  249. }).catch(err => {
  250. })
  251. .finally(() => {
  252. // Loading.close()
  253. })
  254. },
  255. //轮播图
  256. getBanners() {
  257. return request({
  258. url: '/homepage/getBanners',
  259. method: 'post',
  260. data: {
  261. "storeId": this.$store.state.storeInfo.storeId,
  262. "showPosition": 0, //门店0
  263. }
  264. })
  265. },
  266. //消息文字跑马灯
  267. getTiceList() {
  268. return request({
  269. url: '/homepage/noticeList',
  270. method: 'post',
  271. data: {
  272. "storeId": this.$store.state.storeInfo.storeId,
  273. "contentType": "1" //门店1
  274. }
  275. })
  276. },
  277. inPage(index) {
  278. switch (index) {
  279. case 0:
  280. {
  281. this.$u.route({
  282. url: 'pages/home/scancode/index',
  283. })
  284. break;
  285. }
  286. case 1:
  287. {
  288. this.$u.route({
  289. url: 'pages/home/scancode/scancodeout',
  290. })
  291. break;
  292. }
  293. case 2:
  294. {
  295. this.$u.route({
  296. url: 'pages/home/my-stock/my-stock',
  297. })
  298. break;
  299. }
  300. case 3:
  301. {
  302. this.$u.route({
  303. url: 'pages/home/monthly-policy/monthly-policy',
  304. })
  305. break;
  306. }
  307. case 4:
  308. {
  309. this.$u.route({
  310. url: 'pages/home/scancodequery/result',
  311. })
  312. break;
  313. }
  314. case 5:
  315. {
  316. this.$u.route({
  317. url: 'pages/home/Statistical-task/index',
  318. })
  319. break;
  320. }
  321. }
  322. },
  323. },
  324. }
  325. </script>
  326. <style lang="scss" scoped>
  327. .status_bar {
  328. height: var(--status-bar-height);
  329. width: 100%;
  330. background-color: #FFF;
  331. }
  332. </style>