makeApply.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <template>
  2. <view style="background-color: #FF531C;">
  3. <!-- 预约报名 -->
  4. <image src="../../static/apply/bg.png" mode="widthFix" style="width: 100%;" class="bground">
  5. <view class="bground_time">报名时间:{{ sign_start_time }}-{{ sign_end_time }}</view>
  6. <view class="bground_box" v-if="apply === 0">
  7. <view class="title">大卫博士学位争霸赛第{{season}}季</view>
  8. <video id="myVideo" :src="src" controls></video>
  9. <view class="shuoming">赛事规则说明</view>
  10. <view class="apply" @click="$noMultipleClicks(goApply)" >预约报名</view>
  11. </view>
  12. <view class="bground_box" v-if="apply === 1">
  13. <view class="title">大卫博士学位争霸赛第{{season}}季</view>
  14. <image src="../../static/apply/success.png" mode="widthFix" style="width: 260rpx;"></image>
  15. <view class="success">预约成功!</view>
  16. <view style="margin-bottom: 164rpx;text-align: center;">
  17. <view class="tixing">报名开始时会有微信消息提醒,请注意查收!</view>
  18. <view class="tixing">报名时请使用已注册账号。</view>
  19. </view>
  20. </view>
  21. <view class="bground_box" v-if="apply === 2">
  22. <view class="title">大卫博士学位争霸赛第{{season}}季</view>
  23. <image src="../../static/apply/error.png" mode="widthFix" style="width: 260rpx;"></image>
  24. <view class="success">无法报名</view>
  25. <view class="error">抱歉您还不是代理商,暂无法报名!</view>
  26. </view>
  27. </image>
  28. </view>
  29. </template>
  30. <script>
  31. import { GetAppointmentInfo, Appointment } from '../../api.js'
  32. export default {
  33. data() {
  34. return {
  35. noClick:true,
  36. apply: 0,
  37. sign_start_time: '',
  38. sign_end_time: '',
  39. season: '',
  40. src:'https://img.cdn.aliyun.dcloud.net.cn/guide/uniapp/%E7%AC%AC1%E8%AE%B2%EF%BC%88uni-app%E4%BA%A7%E5%93%81%E4%BB%8B%E7%BB%8D%EF%BC%89-%20DCloud%E5%AE%98%E6%96%B9%E8%A7%86%E9%A2%91%E6%95%99%E7%A8%8B@20200317.mp4'
  41. }
  42. },
  43. onShow() {
  44. this.$store.dispatch('onLaunch').then(() => {
  45. this.getAppointment()
  46. }).catch(e => {})
  47. },
  48. methods: {
  49. happenTimeFun(num){//时间戳数据处理
  50. let date = new Date(num*1000);
  51. //时间戳为10位需*1000,时间戳为13位的话不需乘1000
  52. let y = date.getFullYear();
  53. let MM = date.getMonth() + 1;
  54. MM = MM < 10 ? ('0' + MM) : MM;//月补0
  55. let d = date.getDate();
  56. d = d < 10 ? ('0' + d) : d;//天补0
  57. let h = date.getHours();
  58. h = h < 10 ? ('0' + h) : h;//小时补0
  59. let m = date.getMinutes();
  60. m = m < 10 ? ('0' + m) : m;//分钟补0
  61. let s = date.getSeconds();
  62. s = s < 10 ? ('0' + s) : s;//秒补0
  63. return y + '.' + MM + '.' + d;
  64. },
  65. getAppointment() {
  66. uni.showLoading({title: '加载中',mask:true});
  67. this.$ajax.get(`${GetAppointmentInfo}`).then(([, { data: res }]) => {
  68. setTimeout(function () {uni.hideLoading();}, 100);
  69. this.sign_start_time = this.happenTimeFun(Number(res.data.sign_start_time))
  70. this.sign_end_time = this.happenTimeFun(Number(res.data.sign_end_time))
  71. this.season = res.data.season
  72. if (res.data.status === true) {
  73. this.apply = 1
  74. } else {
  75. this.apply = 0
  76. }
  77. })
  78. },
  79. async goApply() {
  80. const res = await uni.getSetting({ withSubscriptions: true })
  81. const go = () => {
  82. this.sureApply()
  83. }
  84. let s;
  85. try {
  86. const [, { subscriptionsSetting: { itemSettings: _s } }] = await uni.getSetting({ withSubscriptions: true })
  87. s = _s
  88. } catch(e) {
  89. go()
  90. return false
  91. }
  92. const tmplIds = [
  93. 't9_3hsUqanNeYNheYEDtsL26VWqCVRrFBaj7QLiSh2M',
  94. '8R9SbxBeziYURpzOqMYQUyd1dCzBKQVuayrpeUr4PSQ',
  95. 'FjXnhSWmUSoCLf-eC1zkNxbojpD7bzoe0U9yVGRZR54'
  96. ]
  97. const t_alen = tmplIds.length
  98. let t_len = 0
  99. if(s) {
  100. const s_k = Object.keys(s)
  101. const s_v = Object.values(s)
  102. t_len = tmplIds.filter(id => s_k.indexOf(id) !== -1).length
  103. }
  104. if(!s || t_len !== t_alen) {
  105. uni.requestSubscribeMessage({
  106. tmplIds,
  107. success(res) {
  108. const _o = Object.assign({}, res)
  109. Reflect.deleteProperty(_o, 'errMsg')
  110. const a_len = Object.values(_o).filter(s => s === 'accept').length
  111. if(a_len !== t_alen){
  112. uni.showModal({
  113. title: '提示',
  114. content: '请选择订阅服务,以便我们通知您活动信息',
  115. showCancel: false
  116. })
  117. } else {
  118. go()
  119. }
  120. },
  121. fail(err) {
  122. uni.showModal({
  123. title: '失败',
  124. content: '打开订阅服务失败',
  125. showCancel: false
  126. })
  127. go()
  128. }
  129. })
  130. } else {
  131. go()
  132. }
  133. },
  134. sureApply() {
  135. this.$ajax.get(`${Appointment}`).then(([, { data: res }]) => {
  136. if (res.code === 200) {
  137. this.apply = 1
  138. } else {
  139. this.apply = 2
  140. }
  141. })
  142. }
  143. }
  144. }
  145. </script>
  146. <style lang="scss" scoped>
  147. page {
  148. width: 100%;
  149. display: flex;
  150. flex-direction: column;
  151. }
  152. .bground {
  153. position: relative;
  154. &_time {
  155. width: 522rpx;
  156. font-size: 32rpx;
  157. font-weight: bold;
  158. line-height: 32rpx;
  159. color: #FFFFFF;
  160. position: absolute;
  161. left: 50%;
  162. top: 450rpx;
  163. margin-left: -242rpx;
  164. }
  165. &_box {
  166. position: absolute;
  167. left: 50%;
  168. top: 420rpx;
  169. margin-left: -345rpx;
  170. width: 690rpx;
  171. height: 924rpx;
  172. border-radius: 24rpx;
  173. padding: 120rpx 0 64rpx 0;
  174. display: flex;
  175. justify-content: space-between;
  176. flex-direction: column;
  177. align-items: center;
  178. color: #333333;
  179. font-weight: bold;
  180. .title {
  181. font-size: 44rpx;
  182. }
  183. .shuoming {
  184. font-size: 32rpx;
  185. }
  186. .apply {
  187. width: 582rpx;
  188. line-height: 100rpx;
  189. background: linear-gradient(179deg, #F7C02F 0%, #F17E06 100%);
  190. opacity: 1;
  191. border-radius: 50rpx;
  192. color: #fff;
  193. font-size: 36rpx;
  194. text-align: center;
  195. }
  196. .success {
  197. font-size: 56rpx;
  198. }
  199. .tixing {
  200. font-size: 30rpx;
  201. line-height: 40rpx;
  202. margin-top: 10rpx;
  203. }
  204. .error {
  205. font-size: 36rpx;
  206. margin-bottom: 212rpx;
  207. }
  208. }
  209. }
  210. </style>