TimeBalance.vue 8.7 KB

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