TimeBalance.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. <template>
  2. <div>
  3. <!-- 计时卡计时 -->
  4. <div class="pfi flex timing" v-if="timingVisible">
  5. <div>{{countdownTime}}</div>
  6. <img class="wh22" :src="closePath" alt="" @click="handlecountdownTimeClose" />
  7. </div>
  8. <!-- 计费规则 -->
  9. <van-dialog v-model="billingRulesVisible" :show-confirm-button="false" class="billing-rules-modal">
  10. <div class="tc">
  11. <img class="billing-rules-img" :src="countdownPath" />
  12. </div>
  13. <div class="tc billing-rules-title">
  14. 计费规则
  15. </div>
  16. <div class="tc">进入云机开始计时,点击退出并下机停止计时。点击退出云机仍处于计时状态。</div>
  17. <div class="tc billing-rules-tips">云机时长剩余:<span class="billing-rules-time">{{countdownTime}}</span>
  18. </div>
  19. <div class="billing-rules-btn" @click="getRecommend">我知道了</div>
  20. </van-dialog>
  21. <!-- 应用推荐 -->
  22. <van-dialog v-model="applyRecommendVisible" :show-confirm-button="false" class="apply-recommend-modal">
  23. <div>
  24. <div class="tc apply-recommend-title">应用推荐</div>
  25. <div class="apply-recommend-list">
  26. <div v-for="(item, index) in recommendList" :key="item.id" :class="['flex w100', {'mt-4': index !== 0}]">
  27. <div class="left flex-align-c">
  28. <img :src="item.imageUrl" alt="">
  29. <div>
  30. <div class="title ellipsis">{{item.filename}}</div>
  31. <div class="download-num">有{{item.installNum}}个人下载</div>
  32. </div>
  33. </div>
  34. <div class="right flex-align-c" @click="downAndInstallApk(item)">
  35. <div>下载</div>
  36. </div>
  37. </div>
  38. </div>
  39. <div class="apply-recommend-btn tc" @click="getRecommend">换一批</div>
  40. </div>
  41. <img class="apply-recommend-close pab" :src="applyClosePath" alt="" @click="applyRecommendVisible = false" />
  42. </van-dialog>
  43. </div>
  44. </template>
  45. <script>
  46. /**
  47. * 计时卡计时
  48. */
  49. export default {
  50. name: 'TimeBalance',
  51. props: {
  52. // 当前云机id
  53. userCardId: {
  54. type: [String, Number],
  55. default: ''
  56. },
  57. // 云机的类型 0 普通套餐 1、2、3:年卡、普通计时、自动续费普通计时
  58. userCardType: {
  59. type: [String, Number],
  60. default: ''
  61. },
  62. // url中获取的参数, 父组件传递
  63. parametersData: {
  64. type: Object,
  65. default: () => ({})
  66. },
  67. },
  68. data() {
  69. return {
  70. // 计时卡是否显示
  71. timingVisible: false,
  72. // 倒计时时间
  73. countdownTime: 0,
  74. // 倒计时定时器
  75. countdownTimeInterval: null,
  76. closePath: '../static/img/close.png',
  77. // 计费规则是否显示
  78. billingRulesVisible: false,
  79. countdownPath: '../rtcEngine/img/countdown.png',
  80. // 应用推荐列表
  81. applyRecommendVisible: false,
  82. // 应用推荐列表数据
  83. recommendList: [],
  84. applyClosePath: '../rtcEngine/img/close.png',
  85. }
  86. },
  87. methods: {
  88. // 获取云机剩余时长
  89. async getResidueTime() {
  90. clearInterval(this.countdownTimeInterval)
  91. const { isShowCountdown, isShowRule } = this.parametersData;
  92. if (![1, 2, 3].includes(+this.userCardType)) return;
  93. const res = await this.$axios.get(`/resources/yearMember/getResidueTime?userCardId=${this.userCardId}`);
  94. let time = res.data;
  95. if (!res.status) {
  96. this.countdownTime = this.residueTimeStamp(time);
  97. await this.$axios.get(`/resources/yearMember/startTime?userCardId=${this.userCardId}`);
  98. // 计时卡显示
  99. if (+isShowCountdown) this.timingVisible = true;
  100. // 计费规则显示
  101. if (+isShowRule) this.billingRulesVisible = true;
  102. // 倒计时退出云机定时器
  103. this.countdownTimeInterval = setInterval(() => {
  104. if (time <= 0) {
  105. clearInterval(this.countdownTimeInterval)
  106. // 退出云机
  107. this.$emit('downline');
  108. return
  109. }
  110. time--
  111. this.countdownTime = residueTimeStamp(time)
  112. }, 1000)
  113. }
  114. },
  115. // 关闭倒计时弹窗
  116. handlecountdownTimeClose() {
  117. this.$axios.get(`/resources/yearMember/closeRemind?userCardId=${this.userCardId}`).then(res => {
  118. if (!res.status) {
  119. clearInterval(this.countdownTimeInterval);
  120. this.timingVisible = false;
  121. return
  122. }
  123. this.$toast(res.msg);
  124. })
  125. },
  126. // 获取推荐列表
  127. getRecommend() {
  128. this.$axios.get(`/public/v1/market/get/recommend?userCardId=${this.userCardId}`).then(res => {
  129. if (!res.status) {
  130. this.billingRulesVisible = false;
  131. this.recommendList = res.data;
  132. this.recommendList.length && (this.applyRecommendVisible = true)
  133. }
  134. })
  135. },
  136. // 倒计时处理的时间
  137. residueTimeStamp(value) {
  138. let theTime = value;//秒
  139. let middle = 0;//分
  140. let hour = 0;//小时
  141. if (theTime > 59) {
  142. middle = parseInt(theTime / 60);
  143. theTime = parseInt(theTime % 60);
  144. }
  145. if (middle > 59) {
  146. hour = parseInt(middle / 60);
  147. middle = parseInt(middle % 60);
  148. }
  149. theTime < 10 ? theTime = '0' + theTime : theTime = theTime
  150. middle < 10 ? middle = '0' + middle : middle = middle
  151. hour < 10 ? hour = '0' + hour : hour = hour
  152. return hour + ':' + middle + ':' + theTime
  153. }
  154. }
  155. }
  156. </script>
  157. <style lang="scss" scoped>
  158. .pfi{position: fixed;}
  159. .tc {text-align: center;}
  160. .timing {
  161. top: 2%;
  162. right: 5%;
  163. padding: 6px 5px 6px 9px;
  164. background: rgba(0, 0, 0, 0.6);
  165. border-radius: 30px;
  166. font-size: 14px;
  167. z-index: 1;
  168. color: #FFF;
  169. & > div {
  170. vertical-align: middle;
  171. height: 20px;
  172. line-height: 20px;
  173. &::after {
  174. border-right: 1px solid #FFFFFF;
  175. content: "";
  176. width: 2px;
  177. height: 45%;
  178. display: inline-block;
  179. vertical-align: middle;
  180. margin-bottom: 3px;
  181. padding: 0 3px;
  182. opacity: 0.3;
  183. }
  184. }
  185. & > img {
  186. width: 20px;
  187. height: 20px;
  188. }
  189. }
  190. // 计费规则
  191. .billing-rules-modal {
  192. text-align: center;
  193. font-size: 14px;
  194. color: #757580;
  195. text-align: center;
  196. }
  197. ::v-deep .billing-rules-modal .van-dialog__content {
  198. padding: 0 28px 28px;
  199. }
  200. .billing-rules-modal .billing-rules-img {
  201. width: 104px;
  202. height: 140px;
  203. }
  204. .billing-rules-modal .billing-rules-title {
  205. font-size: 18px;
  206. font-weight: 600;
  207. color: #363636;
  208. margin-bottom: 5px;
  209. }
  210. .billing-rules-modal .billing-rules-tips {
  211. margin-top: 5px;
  212. }
  213. .billing-rules-modal .billing-rules-time {
  214. color: #00DB88;
  215. font-size: 15px;
  216. }
  217. .billing-rules-modal .billing-rules-btn {
  218. height: 50px;
  219. line-height: 50px;
  220. text-align: center;
  221. margin-top: 24px;
  222. background: linear-gradient(90deg, #00A3FF 0%, #04F79A 100%);
  223. border-radius: 8px;
  224. font-size: 12px;
  225. color: #FFF;
  226. }
  227. // 应用推荐
  228. .apply-recommend-modal {
  229. overflow: visible;
  230. }
  231. ::v-deep .apply-recommend-modal .van-dialog__content {
  232. padding: 10px 28px 28px;
  233. }
  234. .apply-recommend-modal .van-dialog__content > div {
  235. height: 350px;
  236. display: flex;
  237. flex-direction: column;
  238. }
  239. .apply-recommend-modal .van-dialog__content > div .apply-recommend-title {
  240. font-size: 16px;
  241. font-weight: 500;
  242. color: #363636;
  243. }
  244. .apply-recommend-modal .van-dialog__content > div .apply-recommend-list {
  245. flex: 1;
  246. overflow-y: auto;
  247. margin-top: 16px;
  248. }
  249. .apply-recommend-modal .van-dialog__content > div .apply-recommend-list::-webkit-scrollbar {
  250. display: none;
  251. }
  252. .apply-recommend-modal .van-dialog__content > div .apply-recommend-list .left {
  253. width: calc(100% - 68px);
  254. }
  255. .apply-recommend-modal .van-dialog__content > div .apply-recommend-list .left > img {
  256. width: 36px;
  257. height: 36px;
  258. }
  259. .apply-recommend-modal .van-dialog__content > div .apply-recommend-list .left > div {
  260. width: calc(100% - 36px);
  261. padding-left: 10px;
  262. box-sizing: border-box;
  263. }
  264. .apply-recommend-modal .van-dialog__content > div .apply-recommend-list .left .title {
  265. width: 100%;
  266. font-size: 16px;
  267. color: #363636;
  268. max-width: 100%;
  269. }
  270. .apply-recommend-modal .van-dialog__content > div .apply-recommend-list .left .download-num {
  271. font-size: 12px;
  272. color: #757580;
  273. }
  274. .apply-recommend-modal .van-dialog__content > div .apply-recommend-list .right > div {
  275. width: 68px;
  276. height: 30px;
  277. line-height: 30px;
  278. text-align: center;
  279. background: linear-gradient(90deg, #00A3FF 0%, #04F79A 100%);
  280. border-radius: 8px;
  281. font-size: 12px;
  282. color: #FFF;
  283. }
  284. .apply-recommend-modal .van-dialog__content > div .apply-recommend-btn {
  285. height: 50px;
  286. line-height: 50px;
  287. margin-top: 14px;
  288. background: linear-gradient(225deg, #FF62F8 0%, #FF9D5C 100%);
  289. border-radius: 8px;
  290. font-size: 12px;
  291. color: #FFF;
  292. }
  293. .apply-recommend-modal .van-dialog__content .apply-recommend-close {
  294. bottom: -12%;
  295. left: 50%;
  296. transform: translateX(-50%);
  297. width: 38px;
  298. height: 38px;
  299. position: absolute;
  300. }
  301. </style>