chooseCloudPhone.vue 6.7 KB

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