index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <template>
  2. <view class="container">
  3. <navBar title="" :navImg="navImg" :back="false" color="#333333" background="#FFFFFF" />
  4. <!-- 轮播图 -->
  5. <view class="swiperBox">
  6. <u-swiper height="514rpx" :autoplay="false" :list="list1" @change="change" @click="click">
  7. </u-swiper>
  8. </view>
  9. <view class="mainContent">
  10. <view class="topBox">
  11. <view class="left">
  12. <image class="item" v-for="(item,index) in list1" :src="item"
  13. :style="{'margin-left':index==0?'32rpx':'0'}">
  14. </image>
  15. </view>
  16. <view class="right">
  17. <view class="t1">
  18. CHILDREN PICTURE BOO
  19. </view>
  20. <view class="t2">
  21. 专属故事
  22. </view>
  23. <view class="btnBox" @click="toGen">
  24. 即刻代写
  25. <image class="arrIcon">
  26. </image>
  27. </view>
  28. </view>
  29. </view>
  30. <view class="botBox">
  31. <view class="title">
  32. 精选绘本故事
  33. <image class="bookIcon">
  34. </image>
  35. </view>
  36. <view class="list">
  37. <view class="item" v-for="(item,index) in jingxuanList">
  38. <image class="pic" :src="item.sd_image.replace('localhost:8000',baseUrl)" mode="widthFix">
  39. </image>
  40. <view class="des">
  41. {{item.title}}
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. <tabBar :tabBarList="tabBarList" :routePath="routePath" @onTabBar="onTabBar" />
  47. <!-- 隐私弹框 -->
  48. <privacy-popup @confirmP="confirmP" :urlTitle="urlTitle" @cancleP="cancleP"
  49. :showPrivateBox="showPop"></privacy-popup>
  50. </view>
  51. </view>
  52. </template>
  53. <script>
  54. import {
  55. getJingxuan
  56. } from '@/api/index/index.js'
  57. import PrivacyPopup from "@/components/privacyPopup/index.vue";
  58. import uploadUrl from '@/common/config.js'
  59. export default {
  60. components: {
  61. PrivacyPopup
  62. },
  63. data() {
  64. return {
  65. baseUrl:uploadUrl.baseUrl,
  66. jingxuanList:[],
  67. navImg: require('@/static/other/logo.png'),
  68. showPop: false,
  69. urlTitle: '',
  70. list1: [
  71. 'https://cdn.uviewui.com/uview/swiper/swiper1.png',
  72. 'https://cdn.uviewui.com/uview/swiper/swiper2.png',
  73. 'https://cdn.uviewui.com/uview/swiper/swiper3.png',
  74. ],
  75. tabBarList: [{
  76. "pagePath": "pages/index/index",
  77. "iconPath": "../../static/tabbar/index.png",
  78. "selectedIconPath": "../../static/tabbar/index_a.png",
  79. "text": "首页"
  80. },
  81. {
  82. "pagePath": "pages/my/index",
  83. "iconPath": "../../static/tabbar/my.png",
  84. "selectedIconPath": "../../static/tabbar/my_a.png",
  85. "text": "我的"
  86. }
  87. ],
  88. routePath: '',
  89. }
  90. },
  91. onLoad(o) {
  92. uni.hideTabBar()
  93. let routes = getCurrentPages(); // 获取当前打开过的页面路由数组
  94. let curRoute = routes[routes.length - 1].route // 获取当前页面路由,也就是最后一个打开的页面路由
  95. this.routePath = curRoute;
  96. console.log('routePath', this.routePath);
  97. this.getJingxuan()
  98. },
  99. onShow() {
  100. this.handlePrivate()
  101. },
  102. methods: {
  103. async getJingxuan() {
  104. let res1 = await getJingxuan()
  105. console.log('首页精选返回值--------2', res1);
  106. if (res1.code == 0) {
  107. this.jingxuanList=res1.data.data
  108. // this.chargeList=[]
  109. } else {
  110. this.$toast(res1.message)
  111. }
  112. },
  113. toGen() {
  114. uni.navigateTo({
  115. url: '/pages/index/genRes/index'
  116. })
  117. },
  118. handlePrivate() {
  119. let _this = this
  120. if (uni.getPrivacySetting) {
  121. uni.getPrivacySetting({
  122. success: res => {
  123. console.log("是否需要授权--首页:", res.needAuthorization, "隐私协议的名称为:", res
  124. .privacyContractName)
  125. _this.urlTitle = res
  126. .privacyContractName
  127. if (res.needAuthorization) {
  128. getApp().globalData.showPrivacy = true;
  129. _this.showPop = true
  130. } else {
  131. getApp().globalData.showPrivacy = false;
  132. }
  133. },
  134. fail: () => {},
  135. complete: () => {},
  136. })
  137. }
  138. },
  139. confirmP() {
  140. this.showPop = false
  141. },
  142. cancleP() {
  143. let _this = this
  144. uni.showModal({
  145. title: '提示',
  146. content: '拒绝将退出小程序,确定退出?',
  147. success: function(res) {
  148. if (res.confirm) {
  149. _this.showPop = false
  150. wx.exitMiniProgram({
  151. success: function() {
  152. // uni.removeStorageSync('iv'); //清除缓存
  153. }
  154. })
  155. } else if (res.cancel) {
  156. }
  157. }
  158. });
  159. },
  160. onTabBar(e) {
  161. console.log('e------------', e);
  162. uni.switchTab({
  163. url: '/' + e
  164. })
  165. },
  166. async testReq() {
  167. console.log('testStore()111111', this.$store.getters['user/testInfo']);
  168. console.log('testStore()111111', this.$store.getters['user/testInfo2']);
  169. // let res = await getValidateCode({
  170. // phone: '15609038521',
  171. // event: 'register'
  172. // })
  173. // uni.showToast({
  174. // title: res.msg,
  175. // icon: 'none'
  176. // })
  177. // console.log('发送短信验证码返回值', res);
  178. // if (res.code == 0) {}
  179. },
  180. testStore() {
  181. this.$store.dispatch('user/testAct', '6666666')
  182. console.log('testStore()', this.$store.getters['user/testInfo']);
  183. // this.$store.dispatch('testAct', '66666');
  184. // console.log('存入仓库后', this.$store.getters.testInfo);
  185. },
  186. async testLogin() {
  187. let res = await this.$store.dispatch('user/testAct2', {
  188. phone: '15609038533',
  189. event: 'register'
  190. })
  191. console.log('测试登录返回值:', res);
  192. },
  193. testLogout() {
  194. this.$store.dispatch('user/testAct3')
  195. console.log('测试退出登录返回值:', this.$store.getters['user/testInfo3']);
  196. },
  197. }
  198. }
  199. </script>
  200. <style lang="scss" scoped>
  201. @import "./index.scss";
  202. </style>