index.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341
  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. console.log("在这里")
  132. uni.getSystemInfo({
  133. success: res => {
  134. // let add = ''这个不要删除!
  135. // console.log(res)这个不要删除!
  136. },
  137. complete: err => {
  138. if (err.platform == 'android') {
  139. this.onLaunch_s()
  140. console.log("在这里2")
  141. this.platform = err.platform
  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. 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. plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
  224. if (wgtinfo.version == res.data.version) {
  225. this.show_s = false
  226. // uni.showToast({
  227. // icon: 'none',
  228. // title: '已是最新版本',
  229. // position: "bottom"
  230. // })
  231. } else if (wgtinfo.version != res.data.forceVersion) {
  232. this.Copywriting = res.data.msg
  233. this.show_s = true
  234. this.url = res.data.url
  235. this.is_force = true
  236. } else if (wgtinfo.version == res.data.forceVersion) {
  237. this.Copywriting = res.data.msg
  238. this.is_force = false
  239. this.show_s = true
  240. this.url = res.data.url
  241. }
  242. })
  243. }).catch(err => {
  244. })
  245. .finally(() => {
  246. // Loading.close()
  247. })
  248. },
  249. //轮播图
  250. getBanners() {
  251. return request({
  252. url: '/homepage/getBanners',
  253. method: 'post',
  254. data: {
  255. "storeId": this.$store.state.storeInfo.storeId,
  256. "showPosition": 0, //门店0
  257. }
  258. })
  259. },
  260. //消息文字跑马灯
  261. getTiceList() {
  262. return request({
  263. url: '/homepage/noticeList',
  264. method: 'post',
  265. data: {
  266. "storeId": this.$store.state.storeInfo.storeId,
  267. "contentType": "1" //门店1
  268. }
  269. })
  270. },
  271. inPage(index) {
  272. switch (index) {
  273. case 0:
  274. {
  275. this.$u.route({
  276. url: 'pages/home/scancode/index',
  277. })
  278. break;
  279. }
  280. case 1:
  281. {
  282. this.$u.route({
  283. url: 'pages/home/scancode/scancodeout',
  284. })
  285. break;
  286. }
  287. case 2:
  288. {
  289. this.$u.route({
  290. url: 'pages/home/my-stock/my-stock',
  291. })
  292. break;
  293. }
  294. case 3:
  295. {
  296. this.$u.route({
  297. url: 'pages/home/monthly-policy/monthly-policy',
  298. })
  299. break;
  300. }
  301. case 4:
  302. {
  303. this.$u.route({
  304. url: 'pages/home/scancodequery/result',
  305. })
  306. break;
  307. }
  308. case 5:
  309. {
  310. this.$u.route({
  311. url: 'pages/home/Statistical-task/index',
  312. })
  313. break;
  314. }
  315. }
  316. },
  317. },
  318. }
  319. </script>
  320. <style lang="scss" scoped>
  321. .status_bar {
  322. height: var(--status-bar-height);
  323. width: 100%;
  324. background-color: #FFF;
  325. }
  326. </style>