index.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  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="package[langIndex].swiper" :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. <template v-for="(item, index) in package[langIndex].banner">
  18. <u-image width="350rpx" :src="item.img" @tap="$u.throttle(routerPage(item.url), 1000)" mode="widthFix"
  19. class="u-skeleton-fillet"></u-image>
  20. </template>
  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. {{ $t('index.quickService') }}
  25. </view>
  26. <view class="u-flex u-flex-wrap u-row-center">
  27. <template v-for="(item, index) in package[langIndex].service">
  28. <u-image class="u-skeleton-fillet quick-service-item" width="350rpx" height="212rpx" :src="item.img" style="margin:10rpx 10rpx 25rpx 10rpx;box-shadow:0rpx 0rpx 20rpx rgba(0,0,0,0.2);border-radius: 30rpx;"
  29. @click="routerPage(item.url)"></u-image>
  30. </template>
  31. </view>
  32. </view>
  33. <view class="u-flex u-row-center u-m-t-35">
  34. <template v-for="(item, index) in package[langIndex].ad">
  35. <u-image class="u-skeleton-fillet" width="680rpx" :src="item" mode="widthFix"></u-image>
  36. </template>
  37. </view>
  38. </view>
  39. <!-- 与包裹页面所有内容的元素u-page同级,且在它的下方 -->
  40. <!-- <u-tabbar v-model="current" :list="list"></u-tabbar> -->
  41. <u-skeleton :loading="loading" :animation="true"></u-skeleton>
  42. <u-toast ref="ulogin" />
  43. <luo-version-upgrade v-if="show_s == true" :version="platform" :url="url" :is_force="is_force" :describe="Copywriting"></luo-version-upgrade>
  44. </view>
  45. </template>
  46. <script>
  47. import versionUpgrade from "../../components/luo-version-upgrade/luo-version-upgrade.vue";
  48. import {mapState, mapMutations } from 'vuex'
  49. import { request } from '../../common/request/request'
  50. import { indexData } from '../../static/common/data/data.js'
  51. require("promise.prototype.finally").shim()
  52. import axios from 'axios'
  53. export default {
  54. components: {
  55. versionUpgrade
  56. },
  57. data() {
  58. return {
  59. bannersList: [],
  60. noticebarList: [],
  61. loading: true, // 是否显示骨架屏组件
  62. list: [
  63. '../../static/sailun/swiper1.png'
  64. ],
  65. show_s: false,
  66. url: '',
  67. is_force: false,
  68. Copywriting: '',
  69. platform:'',
  70. langIndex: 0,
  71. package: indexData
  72. }
  73. },
  74. onLoad() {
  75. uni.$on('login', (data) => {
  76. this.loginStatus = data.msg
  77. })
  78. // uni.startPullDownRefresh();
  79. },
  80. onReady() {
  81. if (this.loginStatus == "登录成功" || this.loginStatus == "login sucess") {
  82. this.$refs.ulogin.show({
  83. title: this.$t('index.loginSuc'),
  84. })
  85. }
  86. },
  87. created() {
  88. console.log('indexData', indexData)
  89. if (this.hasLogin) {
  90. uni.showLoading({
  91. title: this.$t('unified.Loading')
  92. });
  93. axios.all([this.getBanners(), this.getTiceList()])
  94. .then(axios.spread((one, two) => {
  95. this.bannersList = one.data.data.map(t => t.imgPath)
  96. // console.log(one)
  97. this.noticebarList = two.data.data.map(t => t.msgContent)
  98. }))
  99. .catch(err => {
  100. })
  101. .finally(() => {
  102. this.loading = false;
  103. uni.hideLoading();
  104. })
  105. let lang = localStorage.getItem('lang')
  106. if (lang === 'zh') {
  107. this.langIndex = 0
  108. } else if (lang === 'en') {
  109. this.langIndex = 1
  110. } else {
  111. this.langIndex = 0
  112. }
  113. uni.setTabBarItem({
  114. index: 0,
  115. text: this.$t('tabBar.index')
  116. })
  117. uni.setTabBarItem({
  118. index: 1,
  119. text: this.$t('tabBar.msg')
  120. })
  121. uni.setTabBarItem({
  122. index: 2,
  123. text: this.$t('tabBar.my')
  124. })
  125. }
  126. },
  127. onShow() {
  128. this.system()
  129. },
  130. onPullDownRefresh() {
  131. axios.all([this.getBanners(), this.getTiceList()])
  132. .then(axios.spread((one, two) => {
  133. this.bannersList = one.data.data.map(t => t.imgPath)
  134. this.noticebarList = two.data.data.map(t => t.msgContent)
  135. }))
  136. .catch(err => {
  137. })
  138. .finally(() => {
  139. this.loading = false;
  140. uni.stopPullDownRefresh();
  141. })
  142. },
  143. computed: {
  144. ...mapState(['hasLogin'])
  145. },
  146. methods: {
  147. system() {
  148. uni.getSystemInfo({
  149. success: res => {
  150. this.platform = res.platform
  151. },
  152. complete: err => {
  153. this.platform = err.platform
  154. if (err.platform == 'android') {
  155. this.onLaunch_s()
  156. } else if (err.platform == 'ios') {
  157. //
  158. this.iosstartup()
  159. }
  160. }
  161. });
  162. },
  163. iosstartup() {
  164. request({
  165. url: '/baseReq/apkUpgrade',
  166. method: 'get',
  167. params: {
  168. osType: 1
  169. }
  170. }).then(res => {
  171. plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
  172. //
  173. //版本号
  174. if (wgtinfo.version == res.data.version) {
  175. this.show_s = true
  176. // uni.showToast({
  177. // icon: 'none',
  178. // title: '已是最新版本',
  179. // position: "bottom"
  180. // })
  181. //
  182. } else if (wgtinfo.version != res.data.forceVersion) {
  183. //
  184. res.data.msg = res.data.msg.replace(/\\n/g, "\n")
  185. uni.showModal({
  186. title: this.$t('index.tip1'),
  187. content: res.data.msg,
  188. showCancel: false,
  189. confirmText: this.$t('index.tip2'),
  190. success: function(res) {
  191. if (res.confirm) {
  192. //
  193. let appleId = 1518555723
  194. plus.runtime.launchApplication({
  195. action: `itms-apps://itunes.apple.com/cn/app/id${appleId}?mt=8`
  196. }, function(e) {
  197. });
  198. } else if (res.cancel) {
  199. }
  200. }
  201. })
  202. } else if (wgtinfo.version == res.data.forceVersion) {
  203. res.data.msg = res.data.msg.replace(/\\n/g, "\n")
  204. uni.showModal({
  205. title: this.$t('index.tip1'),
  206. content: res.data.msg,
  207. showCancel: true,
  208. confirmText: this.$t('index.tip2'),
  209. success: function(res) {
  210. if (res.confirm) {
  211. let appleId = 1518555723
  212. plus.runtime.launchApplication({
  213. action: `itms-apps://itunes.apple.com/cn/app/id${appleId}?mt=8`
  214. }, function(e) {
  215. });
  216. } else if (res.cancel) {
  217. }
  218. }
  219. })
  220. }
  221. })
  222. }).catch(err => {
  223. })
  224. .finally(() => {
  225. // Loading.close()
  226. })
  227. },
  228. //升级调用的接口
  229. onLaunch_s() {
  230. request({
  231. url: '/baseReq/apkUpgrade',
  232. method: 'get',
  233. params: {
  234. osType: 0
  235. }
  236. }).then(res =>{
  237. plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
  238. if (wgtinfo.version == res.data.version) {
  239. this.show_s = false
  240. // uni.showToast({
  241. // icon: 'none',
  242. // title: '已是最新版本',
  243. // position: "bottom"
  244. // })
  245. } else if (wgtinfo.version != res.data.forceVersion) {
  246. this.Copywriting = res.data.msg
  247. this.show_s = true
  248. this.url = res.data.url
  249. this.is_force = true
  250. } else if (wgtinfo.version == res.data.forceVersion) {
  251. this.Copywriting = res.data.msg
  252. this.is_force = false
  253. this.show_s = true
  254. this.url = res.data.url
  255. }
  256. })
  257. }).catch(err => {
  258. })
  259. .finally(() => {
  260. // Loading.close()
  261. })
  262. },
  263. //轮播图
  264. getBanners() {
  265. return request({
  266. url: '/homepage/getBanners',
  267. method: 'post',
  268. data: {
  269. "storeId": this.$store.state.storeInfo.storeId,
  270. "showPosition": 0, //门店0
  271. }
  272. })
  273. },
  274. //消息文字跑马灯
  275. getTiceList() {
  276. return request({
  277. url: '/homepage/noticeList',
  278. method: 'post',
  279. data: {
  280. "storeId": this.$store.state.storeInfo.storeId,
  281. "contentType": "1" //门店1
  282. }
  283. })
  284. },
  285. // 当前跳转路由
  286. routerPage(url) {
  287. this.$u.route({
  288. url: url,
  289. })
  290. }
  291. },
  292. }
  293. </script>
  294. <style lang="scss" scoped>
  295. .status_bar {
  296. height: var(--status-bar-height);
  297. width: 100%;
  298. background-color: #FFF;
  299. }
  300. .quick-service-item {
  301. }
  302. </style>