join.vue 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  1. <template>
  2. <app-layout>
  3. <view v-if="join == false">
  4. <view class='top'>
  5. <image :src='stepImg.app_image.ba'></image>
  6. <view class='title'>
  7. <text :class='[`${list.title.length > 14 ? "dare-name" : ""}`]'>{{list.title}}</text>
  8. <text>{{list.step_num}}步挑战赛</text>
  9. </view>
  10. <view class='time'>开始时间:{{list.begin_at ? list.begin_at + ' 00:00' : ''}}</view>
  11. <view class='time end-time'>结束时间:{{list.end_at ? list.end_at + ' 23:59' : ''}}</view>
  12. </view>
  13. <view class='msg'>
  14. <view class='text'>使用{{setting.currency_name ? setting.currency_name : '活力币'}}参赛</view>
  15. <view>
  16. <text class='use-price'>{{list.bail_currency ? list.bail_currency : 0}}</text>个</view>
  17. </view>
  18. <view class='content'>
  19. <view class='content-title'>参赛步骤</view>
  20. <view class='content-body'>
  21. <view class='content-num'>
  22. <image src='./../image/one.png'></image>
  23. </view>
  24. <view class='content-text'>
  25. <view class='step-title'>报名参赛</view>
  26. <view>使用{{list.bail_currency ? list.bail_currency : 0}}个{{setting.currency_name ? setting.currency_name:'活力币'}}参赛</view>
  27. </view>
  28. </view>
  29. <view class='content-body'>
  30. <view class='content-num'>
  31. <image src='./../image/two.png'></image>
  32. </view>
  33. <view class='content-text'>
  34. <view class='step-title'>比赛日行走达{{list.step_num}}步</view>
  35. <view>比赛日完成并提交{{list.step_num}}步行走</view>
  36. </view>
  37. </view>
  38. <view class='content-body'>
  39. <view class='content-num'>
  40. <image src='./../image/three.png'></image>
  41. </view>
  42. <view class='content-text'>
  43. <view class='step-title'>获得{{setting.currency_name ? setting.currency_name:'活力币'}}奖励</view>
  44. <view>挑战结束,达标用户可平分奖池{{setting.currency_name ? setting.currency_name:'活力币'}}</view>
  45. </view>
  46. </view>
  47. </view>
  48. <view @click='subscribe'>
  49. <view class='join'>
  50. <button class='join-btn'>立即报名</button>
  51. </view>
  52. </view>
  53. </view>
  54. </app-layout>
  55. </template>
  56. <script>
  57. import { mapState } from "vuex";
  58. export default {
  59. data() {
  60. return {
  61. list: {},
  62. name: '',
  63. open_date: '',
  64. step_num: 1000,
  65. bail_currency: 1.00,
  66. setting: null,
  67. template_activity: null,
  68. join: false
  69. }
  70. },
  71. computed: {
  72. ...mapState({
  73. stepImg: state => state.mallConfig.plugin.step,
  74. userInfo: state => state.user.info,
  75. })
  76. },
  77. methods: {
  78. getSetting() {
  79. let that = this;
  80. that.$request({
  81. url: that.$api.step.setting,
  82. }).then(response=>{
  83. that.$hideLoading();
  84. if(response.code == 0) {
  85. that.setting = response.data;
  86. that.template_activity = response.data.template_activity;
  87. }else {
  88. uni.showToast({
  89. title: response.msg,
  90. icon: 'none',
  91. duration: 1000
  92. });
  93. }
  94. }).catch(response => {
  95. that.$hideLoading();
  96. });
  97. },
  98. getList(id) {
  99. let that = this;
  100. that.$showLoading({
  101. type: 'global',
  102. text: '加载中...'
  103. });
  104. that.$request({
  105. url: that.$api.step.activity_detail,
  106. data:{
  107. activity_id: id
  108. },
  109. }).then(response=>{
  110. that.getSetting();
  111. if(response.code == 0) {
  112. that.list = response.data.list;
  113. }else {
  114. uni.showToast({
  115. title: response.msg,
  116. icon: 'none',
  117. duration: 1000
  118. });
  119. }
  120. }).catch(response => {
  121. that.$hideLoading();
  122. });
  123. },
  124. subscribe() {
  125. this.$subscribe(this.template_activity).then(res => {
  126. this.apply();
  127. }).catch(res => {
  128. this.apply();
  129. });
  130. },
  131. apply() {
  132. let that = this;
  133. let id = that.list.id;
  134. uni.showLoading({
  135. title: '报名中...'
  136. });
  137. that.$request({
  138. url: that.$api.step.activity_join,
  139. data: {
  140. activity_id: id
  141. },
  142. method: 'POST',
  143. }).then(response => {
  144. uni.hideLoading();
  145. if (response.code == 0) {
  146. let date = that.list.begin_at;
  147. uni.redirectTo({
  148. url: '/plugins/step/dare/dare?join=1&date='+date
  149. })
  150. } else {
  151. uni.showToast({
  152. title: response.msg,
  153. icon: 'none',
  154. duration: 1000
  155. });
  156. }
  157. }).catch(response => {
  158. uni.hideLoading();
  159. uni.showToast({
  160. title: response,
  161. icon: 'none',
  162. duration: 1000
  163. });
  164. });
  165. },
  166. },
  167. onLoad(options) {
  168. let that = this;
  169. that.getList(options.id);
  170. }
  171. }
  172. </script>
  173. <style scoped lang="scss">
  174. .top {
  175. height: #{200rpx};
  176. color: #fff;
  177. font-size: #{32rpx};
  178. text-align: center;
  179. position: relative;
  180. }
  181. .top image{
  182. width: 100%;
  183. height: 100%;
  184. }
  185. .title {
  186. position: absolute;
  187. width: 100%;
  188. text-align: center;
  189. top: #{35rpx};
  190. height: #{35rpx};
  191. line-height: #{35rpx};
  192. }
  193. .dare-name{
  194. display: inline-block;
  195. width: 65%;
  196. overflow: hidden;
  197. text-overflow: ellipsis;
  198. white-space: nowrap;
  199. height: #{35rpx};
  200. line-height: #{35rpx};
  201. margin-bottom: #{-3rpx};
  202. }
  203. .time{
  204. position: absolute;
  205. width: 100%;
  206. font-size: #{26rpx};
  207. text-align: center;
  208. top: #{80rpx};
  209. }
  210. .time.end-time {
  211. top:#{110rpx};
  212. }
  213. .msg {
  214. height: #{200rpx};
  215. width: 93.6%;
  216. background-color: white;
  217. margin: 0 #{24rpx};
  218. color: #999;
  219. text-align: center;
  220. font-size: #{26rpx};
  221. padding: #{40rpx} #{40rpx};
  222. border-radius: #{16rpx};
  223. position: absolute;
  224. top: #{160rpx};
  225. }
  226. .text {
  227. margin-bottom: #{18rpx};
  228. }
  229. .use-price {
  230. font-size: #{68rpx};
  231. font-family: 'DIN';
  232. color: #ff9d1e;
  233. margin-right: #{6rpx};
  234. }
  235. .content {
  236. background-color: white;
  237. margin-top: #{180rpx};
  238. font-size: #{30rpx};
  239. color: #999;
  240. padding-bottom: #{50rpx};
  241. }
  242. .content-title {
  243. padding-left: #{24rpx};
  244. height: #{87rpx};
  245. line-height: #{87rpx};
  246. border-bottom: #{1rpx} solid #e2e2e2;
  247. color: #353535;
  248. }
  249. .content-body {
  250. padding: #{40rpx} #{56rpx} #{30rpx};
  251. }
  252. .content-num {
  253. float: left;
  254. height: #{80rpx};
  255. width: #{40rpx};
  256. margin-right: #{32rpx};
  257. }
  258. .content-num image {
  259. height: #{40rpx};
  260. width: #{40rpx};
  261. }
  262. .step-title {
  263. font-size: #{32rpx};
  264. color: #353535;
  265. margin-bottom: #{10rpx};
  266. }
  267. .join {
  268. position: fixed;
  269. bottom: 0;
  270. height: #{150rpx};
  271. width: 100%;
  272. background-color: white;
  273. padding: #{35rpx} 0;
  274. }
  275. .join-btn {
  276. height: #{80rpx};
  277. width: #{702rpx};
  278. font-size: #{34rpx};
  279. color: #fffefe;
  280. background: linear-gradient(to right, #ff9d1e, #ffb71e);
  281. border-radius: #{40rpx};
  282. }
  283. button::after {
  284. border: none
  285. }
  286. </style>