swiper.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. <template>
  2. <view class="swiper">
  3. <swiper class="swiper" circular indicator-dots="true" autoplay indicator-active-color="#fff"
  4. indicator-color="rgba(255,255,255,0.5)">
  5. <block v-for="(item,index) of swiperList" :key='index'>
  6. <swiper-item>
  7. <!-- #ifdef MP-ALIPAY -->
  8. <image v-if="item.type==4" @click="bindPath(index)" :src="URL+item.thumb" class="img"></image>
  9. <!-- #endif -->
  10. <!-- #ifdef MP-WEIXIN -->
  11. <button v-if="item.type==4" hover-class="none" class="img" open-type="getPhoneNumber"
  12. @getphonenumber="onGetphoneNumber">
  13. <image :src="URL+item.thumb" class="img"></image>
  14. </button>
  15. <!-- #endif -->
  16. <image v-if="item.type!=4" @click="bindPath(index)" :src="URL+item.thumb" class="img"></image>
  17. </swiper-item>
  18. </block>
  19. </swiper>
  20. <gbClose />
  21. <Vphone :getPhonePop="getPhonePop" @close="setClose"></Vphone>
  22. </view>
  23. </template>
  24. <script>
  25. import Vphone from '@/components/v-phone/v-phone.vue';
  26. import gbClose from './close.vue';
  27. import {
  28. mapState,
  29. } from 'vuex'
  30. export default {
  31. components: {
  32. gbClose,
  33. Vphone
  34. },
  35. computed: {
  36. ...mapState(['systemInfo', 'store_id', 'userInfo', 'swiperList', 'setColor']),
  37. },
  38. data() {
  39. return {
  40. URL: getApp().globalData.URL,
  41. getPhonePop: false,
  42. }
  43. },
  44. onLoad() {
  45. },
  46. methods: {
  47. bindPath(index) {
  48. let {
  49. type,
  50. url
  51. } = this.swiperList[index];
  52. if (type == 0) {
  53. return
  54. }
  55. if (type == 2) {
  56. if ("/pages/index/index" == url) {
  57. console.log(url, "url")
  58. uni.switchTab({
  59. url: url
  60. })
  61. return
  62. }
  63. uni.navigateTo({
  64. url: url
  65. })
  66. }
  67. if (type == 1) {
  68. uni.navigateToMiniProgram({
  69. appId: url,
  70. success(res) {
  71. // 打开成功
  72. }
  73. })
  74. }
  75. if (type == 3) {
  76. uni.setStorageSync("web", url)
  77. uni.navigateTo({
  78. url: "/pages/web/web"
  79. })
  80. }
  81. if (type == 4) {
  82. if (this.userInfo.mobile) {
  83. uni.showToast({
  84. title: "您已经完善过会员信息了,无需重复操作!",
  85. icon: 'none'
  86. })
  87. return
  88. }
  89. this.getPhonePop = true;
  90. }
  91. },
  92. onGetphoneNumber(e) {
  93. if (this.userInfo.mobile) {
  94. uni.showToast({
  95. title: "您已经完善过会员信息了,无需重复操作!",
  96. icon: 'none'
  97. })
  98. return
  99. }
  100. // #ifdef MP-WEIXIN
  101. if (e.detail.errMsg == "getPhoneNumber:ok") {
  102. this.$http.request('xcx/Jiemi', {
  103. id: this.userInfo.id,
  104. data: e.detail.encryptedData,
  105. iv: e.detail.iv,
  106. sessionKey: uni.getStorageSync('user_xcx_info').session_key,
  107. store_id: this.store_id,
  108. }, "", "", true).then(res => {
  109. this.phoneNumber = res.data.phoneNumber;
  110. uni.setStorageSync('phone', res.data.phoneNumber);
  111. uni.showModal({
  112. title: '授权成功',
  113. content: '享受更多优惠!',
  114. showCancel: false,
  115. cancelText: '',
  116. confirmText: '确定',
  117. success: res => {
  118. let subscribe = uni.getStorageSync('balance_subscribe');
  119. uni.requestSubscribeMessage({
  120. tmplIds: [subscribe.member_tid],
  121. success: (r) => {
  122. // console.log(r, "success")
  123. },
  124. complete: (r) => {
  125. // console.log(r, "complete")
  126. uni.switchTab({
  127. url: "../../pages/my/my"
  128. })
  129. }
  130. })
  131. },
  132. fail: () => {},
  133. complete: () => {}
  134. });
  135. })
  136. } else {
  137. uni.showToast({
  138. title: "授权失败,请重新授权",
  139. icon: 'none'
  140. })
  141. }
  142. // #endif
  143. },
  144. // 子组件传参
  145. setClose(e) {
  146. this.getPhonePop = e;
  147. },
  148. // 开启会员弹窗
  149. onGetphone(e) {
  150. // console.log("gggggggggggg",this.userInfo.mobile)
  151. if (this.userInfo.mobile) {
  152. uni.showToast({
  153. title: "您已经完善过会员信息了,无需重复操作!",
  154. icon: 'none'
  155. })
  156. return
  157. }
  158. this.getPhonePop = true;
  159. // this.$emit("getPhonePop",true)
  160. },
  161. }
  162. }
  163. </script>
  164. <style lang="scss" scoped>
  165. .swiper {
  166. width: 550rpx;
  167. height: 550rpx;
  168. margin: 0 auto;
  169. border-radius: 10rpx;
  170. background-color: #FFFFFF;
  171. margin-top: -200rpx;
  172. .img {
  173. display: block;
  174. width: 100%;
  175. height: 100%;
  176. border-radius: 10rpx;
  177. }
  178. button::after {
  179. border: none;
  180. }
  181. button {
  182. background-color: transparent;
  183. padding-left: 0;
  184. padding-right: 0;
  185. line-height: inherit;
  186. }
  187. button {
  188. border-radius: 0;
  189. }
  190. }
  191. </style>