chooseCloudPhone.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. <template>
  2. <layout @goBack="leaveFun" :isNavBar="isNavBar" :bgHeight="350">
  3. <div class="choose-cloud-phone">
  4. <div class="choose-cloud-phone_info">
  5. <div class="choose-cloud-phone_info-name">
  6. 亲爱的{{ info.phoneNumber || '用户' }}
  7. </div>
  8. <img
  9. class="choose-cloud-phone_tips"
  10. src="@/assets/image/claimCloudPhone/chooseCloudPhoneTitle.png"
  11. alt=""
  12. />
  13. </div>
  14. <div class="choose-cloud-phone_select">
  15. <div>请选择</div>
  16. <div v-for="item in 2" :key="item" @click="selectJumpPhone(item)"></div>
  17. </div>
  18. <cloudMobilePhonePopup
  19. v-model="visible"
  20. titleText="选择续费云手机"
  21. :ids.sync="ids"
  22. @confirm="selectJumpPhone(3)"
  23. :data="packageList"
  24. :total="packageTotal"
  25. :loading="loading"
  26. :listLoading.sync="listLoading"
  27. @load="load"
  28. >
  29. <van-search
  30. v-model="keyWord"
  31. placeholder="请输入云机名称"
  32. style="padding: 0; width: 170px"
  33. @input="search"
  34. />
  35. </cloudMobilePhonePopup>
  36. </div>
  37. <van-dialog
  38. v-model="dialogVisible"
  39. :showConfirmButton="false"
  40. close-on-click-overlay
  41. :before-close="beforeClose"
  42. >
  43. <img
  44. v-cloak
  45. src="@/assets/image/claimCloudPhone/firstScreenPopUp.png"
  46. alt=""
  47. ref="dialogImg"
  48. class="dialog-img"
  49. @click="beforeClose"
  50. />
  51. </van-dialog>
  52. </layout>
  53. </template>
  54. <script>
  55. import debounce from 'lodash.debounce';
  56. import common from './mixins/common.js';
  57. import layout from './components/layout.vue';
  58. import cloudMobilePhonePopup from '@/components/cloudMobilePhonePopup';
  59. let _self = null;
  60. export default {
  61. name: 'chooseCloudPhone',
  62. auth: false,
  63. head: {
  64. title: '0元购机,尽情享受',
  65. },
  66. mixins: [common],
  67. components: {
  68. layout,
  69. cloudMobilePhonePopup,
  70. },
  71. data() {
  72. return {
  73. visible: false, // 显示续费云手机弹窗
  74. ids: [], // 选中的id
  75. // 续费云手机套餐相关参数
  76. pageNum: 1,
  77. pageSize: 50,
  78. keyWord: '', // 搜索云手机关键词
  79. packageList: [],
  80. packageTotal: 0,
  81. loading: false,
  82. listLoading: false,
  83. isNavBar: true,
  84. info: {},
  85. dialogVisible: false,
  86. };
  87. },
  88. mounted() {
  89. if (localStorage.getItem('bargainingStatusInfo')) {
  90. this.info = JSON.parse(localStorage.getItem('bargainingStatusInfo'));
  91. }
  92. if (+sessionStorage.getItem('activityEmd')) {
  93. this.dialogVisible = false;
  94. this.$toast('活动已到期');
  95. return;
  96. }
  97. setTimeout(() => {
  98. this.dialogVisible = true;
  99. })
  100. this.isNavBar = !+localStorage.getItem('auth.inviteeNum');
  101. _self = this;
  102. // 用来监听微信返回上一页的
  103. const { exit } = this.$route.query;
  104. if (exit) {
  105. this.wxIntercept(() => {
  106. this.leaveFun();
  107. });
  108. }
  109. this.getRenewalPackage();
  110. },
  111. methods: {
  112. // 选增新增云手机 of 续费云手机
  113. selectJumpPhone(item) {
  114. if (+sessionStorage.getItem('activityEmd')) {
  115. this.$toast('活动已到期');
  116. return;
  117. }
  118. if (item === 2) {
  119. this.ids = [];
  120. this.visible = true;
  121. return;
  122. }
  123. let url = '/claimCloudPhone/zeroYuanClaim';
  124. if (item === 3) url += `?userCardId=${this.ids[0].id}`;
  125. this.$router.push(url);
  126. },
  127. // 搜索云机名称
  128. search: debounce(() => {
  129. _self.pageNum = 1;
  130. _self.packageList = [];
  131. _self.getRenewalPackage();
  132. }, 500),
  133. // 获取续费套餐
  134. getRenewalPackage(bool = true) {
  135. if (bool) this.loading = true;
  136. this.$axios
  137. .$post('resources/v5/activity/card/bargaining/list', {
  138. diskName: this.keyWord,
  139. pageNum: this.pageNum,
  140. pageSize: this.pageSize,
  141. })
  142. .then((res) => {
  143. if (res.success) {
  144. this.packageList.push(...res.data.list);
  145. this.packageTotal = res.data.total;
  146. }
  147. })
  148. .finally(() => {
  149. this.loading = false;
  150. !bool && (this.listLoading = false);
  151. });
  152. },
  153. // 触发续费云手机套餐分页
  154. load() {
  155. this.pageNum++;
  156. this.getRenewalPackage(false);
  157. },
  158. // 动画
  159. beforeClose(action, done) {
  160. this.$refs.dialogImg.className += ' dialog-img-animation';
  161. this.$refs.dialogImg.addEventListener('animationend', () => {
  162. done ? done() : (this.dialogVisible = false);
  163. });
  164. },
  165. },
  166. };
  167. </script>
  168. <style lang="scss" scoped>
  169. .choose-cloud-phone {
  170. height: 100%;
  171. .choose-cloud-phone_info {
  172. .choose-cloud-phone_info-name {
  173. display: inline-block;
  174. padding: 5px 10px;
  175. background: linear-gradient(296deg, #fdf0e2 0%, #fcd9ae 100%);
  176. box-shadow: 0px 1px 2px 0px #facd8a;
  177. border-radius: 4px;
  178. font-family: AlibabaPuHuiTi, AlibabaPuHuiTi;
  179. font-weight: bold;
  180. font-size: 14px;
  181. color: #754213;
  182. line-height: 20px;
  183. text-align: center;
  184. font-style: normal;
  185. margin-bottom: 4px;
  186. }
  187. }
  188. .choose-cloud-phone_tips {
  189. width: 260px;
  190. }
  191. .choose-cloud-phone_select {
  192. margin-top: 10px;
  193. & > div {
  194. margin-bottom: 12px;
  195. }
  196. & > div:nth-of-type(1) {
  197. font-family: PingFangSC, PingFang SC;
  198. font-weight: 500;
  199. font-size: 16px;
  200. color: #ffffff;
  201. line-height: 20px;
  202. font-style: normal;
  203. }
  204. & > div:nth-of-type(2) {
  205. background: url(~/assets/image/claimCloudPhone/addCloudMobilePhone.png)
  206. no-repeat;
  207. }
  208. & > div:nth-of-type(3) {
  209. background: url(~/assets/image/claimCloudPhone/renewCloudMobilePhone.png)
  210. no-repeat;
  211. }
  212. & > div:nth-of-type(2),
  213. & > div:nth-of-type(3) {
  214. height: 123px;
  215. background-size: 100% 100%;
  216. background-position: 0px 0px;
  217. }
  218. }
  219. }
  220. .van-dialog {
  221. background: transparent;
  222. overflow: initial;
  223. .dialog-img {
  224. width: 100%;
  225. height: 100%;
  226. &.dialog-img-animation {
  227. animation: dialogImg 0.5s forwards linear;
  228. @keyframes dialogImg {
  229. 0% {
  230. opacity: 1;
  231. }
  232. 100% {
  233. transform: translate(-39%, -73%) scale(0.2);
  234. opacity: 0;
  235. }
  236. }
  237. }
  238. }
  239. }
  240. </style>