index.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338
  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="platform" :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. platform:''
  76. }
  77. },
  78. onLoad() {
  79. uni.$on('login', (data) => {
  80. this.loginStatus = data.msg
  81. })
  82. // uni.startPullDownRefresh();
  83. },
  84. onReady() {
  85. if (this.loginStatus == "登录成功") {
  86. this.$refs.ulogin.show({
  87. title: "登录成功",
  88. })
  89. }
  90. },
  91. created() {
  92. if (this.hasLogin) {
  93. uni.showLoading({
  94. title: '加载中...'
  95. });
  96. axios.all([this.getBanners(), this.getTiceList()])
  97. .then(axios.spread((one, two) => {
  98. this.bannersList = one.data.data.map(t => t.imgPath)
  99. // console.log(one)
  100. this.noticebarList = two.data.data.map(t => t.msgContent)
  101. }))
  102. .catch(err => {
  103. })
  104. .finally(() => {
  105. this.loading = false;
  106. uni.hideLoading();
  107. })
  108. }
  109. },
  110. onShow() {
  111. this.system()
  112. },
  113. onPullDownRefresh() {
  114. axios.all([this.getBanners(), this.getTiceList()])
  115. .then(axios.spread((one, two) => {
  116. this.bannersList = one.data.data.map(t => t.imgPath)
  117. this.noticebarList = two.data.data.map(t => t.msgContent)
  118. }))
  119. .catch(err => {
  120. })
  121. .finally(() => {
  122. this.loading = false;
  123. uni.stopPullDownRefresh();
  124. })
  125. },
  126. computed: {
  127. ...mapState(['hasLogin'])
  128. },
  129. methods: {
  130. system() {
  131. uni.getSystemInfo({
  132. success: res => {
  133. this.platform = res.platform
  134. },
  135. complete: err => {
  136. this.platform = err.platform
  137. if (err.platform == 'android') {
  138. this.onLaunch_s()
  139. } else if (err.platform == 'ios') {
  140. //
  141. this.iosstartup()
  142. }
  143. }
  144. });
  145. },
  146. iosstartup() {
  147. request({
  148. url: '/baseReq/apkUpgrade',
  149. method: 'get',
  150. params: {
  151. osType: 1
  152. }
  153. }).then(res => {
  154. plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
  155. //
  156. //版本号
  157. if (wgtinfo.version == res.data.version) {
  158. this.show_s = true
  159. // uni.showToast({
  160. // icon: 'none',
  161. // title: '已是最新版本',
  162. // position: "bottom"
  163. // })
  164. //
  165. } else if (wgtinfo.version != res.data.forceVersion) {
  166. //
  167. res.data.msg = res.data.msg.replace(/\\n/g, "\n")
  168. uni.showModal({
  169. title: "发现新版本",
  170. content: res.data.msg,
  171. showCancel: false,
  172. confirmText: "立即去AppStore更新",
  173. success: function(res) {
  174. if (res.confirm) {
  175. //
  176. let appleId = 1518555723
  177. plus.runtime.launchApplication({
  178. action: `itms-apps://itunes.apple.com/cn/app/id${appleId}?mt=8`
  179. }, function(e) {
  180. });
  181. } else if (res.cancel) {
  182. }
  183. }
  184. })
  185. } else if (wgtinfo.version == res.data.forceVersion) {
  186. res.data.msg = res.data.msg.replace(/\\n/g, "\n")
  187. uni.showModal({
  188. title: "发现新版本",
  189. content: res.data.msg,
  190. showCancel: true,
  191. confirmText: "立即去AppStore更新",
  192. success: function(res) {
  193. if (res.confirm) {
  194. let appleId = 1518555723
  195. plus.runtime.launchApplication({
  196. action: `itms-apps://itunes.apple.com/cn/app/id${appleId}?mt=8`
  197. }, function(e) {
  198. });
  199. } else if (res.cancel) {
  200. }
  201. }
  202. })
  203. }
  204. })
  205. }).catch(err => {
  206. })
  207. .finally(() => {
  208. // Loading.close()
  209. })
  210. },
  211. //升级调用的接口
  212. onLaunch_s() {
  213. request({
  214. url: '/baseReq/apkUpgrade',
  215. method: 'get',
  216. params: {
  217. osType: 0
  218. }
  219. }).then(res =>{
  220. plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
  221. if (wgtinfo.version == res.data.version) {
  222. this.show_s = false
  223. // uni.showToast({
  224. // icon: 'none',
  225. // title: '已是最新版本',
  226. // position: "bottom"
  227. // })
  228. } else if (wgtinfo.version != res.data.forceVersion) {
  229. this.Copywriting = res.data.msg
  230. this.show_s = true
  231. this.url = res.data.url
  232. this.is_force = true
  233. } else if (wgtinfo.version == res.data.forceVersion) {
  234. this.Copywriting = res.data.msg
  235. this.is_force = false
  236. this.show_s = true
  237. this.url = res.data.url
  238. }
  239. })
  240. }).catch(err => {
  241. })
  242. .finally(() => {
  243. // Loading.close()
  244. })
  245. },
  246. //轮播图
  247. getBanners() {
  248. return request({
  249. url: '/homepage/getBanners',
  250. method: 'post',
  251. data: {
  252. "storeId": this.$store.state.storeInfo.storeId,
  253. "showPosition": 0, //门店0
  254. }
  255. })
  256. },
  257. //消息文字跑马灯
  258. getTiceList() {
  259. return request({
  260. url: '/homepage/noticeList',
  261. method: 'post',
  262. data: {
  263. "storeId": this.$store.state.storeInfo.storeId,
  264. "contentType": "1" //门店1
  265. }
  266. })
  267. },
  268. inPage(index) {
  269. switch (index) {
  270. case 0:
  271. {
  272. this.$u.route({
  273. url: 'pages/home/scancode/index',
  274. })
  275. break;
  276. }
  277. case 1:
  278. {
  279. this.$u.route({
  280. url: 'pages/home/scancode/scancodeout',
  281. })
  282. break;
  283. }
  284. case 2:
  285. {
  286. this.$u.route({
  287. url: 'pages/home/my-stock/my-stock',
  288. })
  289. break;
  290. }
  291. case 3:
  292. {
  293. this.$u.route({
  294. url: 'pages/home/monthly-policy/monthly-policy',
  295. })
  296. break;
  297. }
  298. case 4:
  299. {
  300. this.$u.route({
  301. url: 'pages/home/scancodequery/result',
  302. })
  303. break;
  304. }
  305. case 5:
  306. {
  307. this.$u.route({
  308. url: 'pages/home/Statistical-task/index',
  309. })
  310. break;
  311. }
  312. }
  313. },
  314. },
  315. }
  316. </script>
  317. <style lang="scss" scoped>
  318. .status_bar {
  319. height: var(--status-bar-height);
  320. width: 100%;
  321. background-color: #FFF;
  322. }
  323. </style>