index.vue 10 KB

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