activitySave.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  1. <template>
  2. <view style="height: 100%; background: #F8F9FA;">
  3. <view class="huodong-ccontent" >
  4. <view style=" height:176rpx;width:176rpx">
  5. <van-image
  6. height="176rpx"
  7. :src="activityInfo.cover"
  8. width="176rpx"
  9. />
  10. </view>
  11. <view class="activity-content">
  12. <view class="activity-title">{{activityInfo.name}}</view>
  13. <view class="activity-date">
  14. <span >{{activityInfo.start_time}}</span>
  15. </view>
  16. <view class="activity-price">
  17. <span ><span style="font-size: 32rpx;color: #C29556">¥{{activityInfo.fee}}</span></span>
  18. </view>
  19. </view>
  20. </view>
  21. <view class="activity-content-title">
  22. 报名信息
  23. </view>
  24. <van-cell-group>
  25. <van-field
  26. v-model="formData.username"
  27. label="姓名"
  28. placeholder="请填写联系人姓名"
  29. :readonly="is_entry&&MyActivityInfo.status==3"
  30. input-align="right"
  31. @change="onChangeUsername"
  32. />
  33. <van-field
  34. v-model="formData.mobile"
  35. :readonly="is_entry&&MyActivityInfo.status==3"
  36. label="联系电话"
  37. type="number"
  38. placeholder="请填写电话号码"
  39. input-align="right"
  40. @change="onChangeMobiler"
  41. />
  42. <van-cell title="报名人数" >
  43. <template #default>
  44. <van-stepper v-model="formData.num" :disabled="is_entry" @change="onChangeStepper"/>
  45. </template>
  46. </van-cell>
  47. <van-cell title="报名时间" v-if="is_entry" :value="activityInfo.entry_info.created_at"/>
  48. </van-cell-group>
  49. <van-toast id="van-toast"/>
  50. <view class="bottom-navigation">
  51. <view class="bottom-navigation-div" v-if="!is_entry">
  52. 应付款: <span>¥<span style="font-size: 40rpx;">{{ activityInfo.fee * formData.num}}</span></span>
  53. </view>
  54. <view class="bottom-navigation-div" v-else-if="is_entry&&MyActivityInfo.status!=3">
  55. 应付款: <span>¥<span style="font-size: 40rpx;">{{ MyActivityInfo.amount_real}}</span></span>
  56. </view>
  57. <view class="bottom-navigation-div" v-else-if="is_entry&&MyActivityInfo.status==3">
  58. 已付款: <span>¥<span style="font-size: 40rpx;">{{ MyActivityInfo.amount_real}}</span></span>
  59. </view>
  60. <button class="activity-button" v-if="!is_entry" @click="handleRegister">立即报名</button>
  61. <button class="activity-button" v-else-if="is_entry&&MyActivityInfo.status!=3" @click="handleEntryUpdate">修改报名信息</button>
  62. </view>
  63. </view>
  64. </template>
  65. <script>
  66. import Toast from "../../wxcomponents/vant/dist/toast/toast";
  67. import {getActivityDetail,addActivityEntry,getMyActivity,entryUpdate} from "../../common/api/activity";
  68. export default {
  69. components: {
  70. },
  71. data() {
  72. return {
  73. data: [],
  74. activityId: 0,
  75. activityInfo:{},
  76. MyActivityInfo:{},
  77. is_entry:false,
  78. entryId:0,
  79. formData:{
  80. mobile:"",
  81. username:'',
  82. num:1,
  83. }
  84. };
  85. },
  86. onLoad: function (option) {
  87. this.activityId = option.activityId
  88. this.getActivityDetail()
  89. },
  90. onShow() {
  91. this.$nextTick(() => {
  92. });
  93. },
  94. onReachBottom() {
  95. },
  96. onShareAppMessage(res) {
  97. let params = {};
  98. params = {
  99. activityId: this.activityId
  100. };
  101. let configs = uni.getStorageSync('configs') || {};
  102. return {
  103. title: configs.shop_share_title,
  104. imageUrl: configs.shop_share_img,
  105. path: `/subPages/activityDetail/activityDetail${this.$stringPageOptions(params)}`
  106. };
  107. },
  108. onShareTimeline(res) {
  109. let params = {};
  110. params = {
  111. activityId: this.activityId
  112. };
  113. let configs = uni.getStorageSync('configs') || {};
  114. return {
  115. title: configs.shop_share_title,
  116. imageUrl: configs.shop_share_img,
  117. path: `/subPages/activityDetail/activityDetail${this.$stringPageOptions(params)}`
  118. };
  119. },
  120. computed: {},
  121. watch: {},
  122. methods: {
  123. getActivityDetail() {
  124. getActivityDetail({id: this.activityId}).then(({data}) => {
  125. this.activityInfo = data
  126. this.activityInfo.start_time = (new Date(this.activityInfo.start_time.replace(' ', 'T'))).toISOString().slice(0, 16).replace('T', ' ');
  127. this.activityInfo.end_time = (new Date(this.activityInfo.end_time.replace(' ', 'T'))).toISOString().slice(0, 16).replace('T', ' ');
  128. this.activityInfo.entry_end = (new Date(this.activityInfo.entry_end.replace(' ', 'T'))).toISOString().slice(0, 16).replace('T', ' ');
  129. if (data.entry_info != []&&data.entry_info.id) {
  130. this.entryId=data.entry_info.id
  131. this.is_entry=true
  132. this.getMyActivity()
  133. }
  134. });
  135. },
  136. getMyActivity() {
  137. getMyActivity({id:this.entryId}).then(({data}) => {
  138. this.MyActivityInfo = data
  139. this.formData.username=data.username
  140. this.formData.mobile=data.mobile
  141. this.formData.num=data.num
  142. });
  143. },
  144. handleRegister() {
  145. if (!this.formData.username){
  146. Toast('请输入姓名');
  147. }
  148. if (!this.formData.mobile){
  149. Toast('请输入手机号');
  150. }
  151. // 正则判断纯数字
  152. if (!/^[0-9]*$/.test(this.formData.mobile)) {
  153. Toast('手机号格式不正确');
  154. return;
  155. }
  156. this.formData.id=this.activityId
  157. addActivityEntry(this.formData).then(({data}) => {
  158. Toast('报名成功');
  159. this.getActivityDetail()
  160. });
  161. },
  162. handleEntryUpdate() {
  163. if (!this.formData.username){
  164. Toast('请输入姓名');
  165. }
  166. if (!this.formData.mobile){
  167. Toast('请输入手机号');
  168. }
  169. // 正则判断纯数字
  170. if (!/^[0-9]*$/.test(this.formData.mobile)) {
  171. Toast('手机号格式不正确');
  172. return;
  173. }
  174. this.formData.id=this.entryId
  175. entryUpdate(this.formData).then(({data}) => {
  176. Toast('修改成功');
  177. this.getActivityDetail()
  178. });
  179. },
  180. onChangeStepper(event){
  181. this.formData.num=event.detail
  182. },
  183. onChangeMobiler(event){
  184. this.formData.mobile=event.detail
  185. },
  186. onChangeUsername(event){
  187. this.formData.username=event.detail
  188. }
  189. },
  190. };
  191. </script>
  192. <style lang="scss" scoped>
  193. .common-page {
  194. height: 100%;
  195. padding: 30rpx;
  196. }
  197. .bottom-navigation{
  198. position: fixed;
  199. // 文字垂直居中
  200. display: flex;
  201. align-items: center;
  202. bottom: 0;
  203. height: 100rpx;
  204. width: calc(100% - 40rpx);
  205. background: #FFFFFF;
  206. box-shadow: 0rpx -2rpx 0rpx 0rpx #F1F3F6;
  207. border-radius: 24rpx 24rpx 0rpx 0rpx;
  208. border: 0rpx solid #979797;
  209. padding: 20rpx 20rpx 68rpx 20rpx ;
  210. &-div{
  211. height: 76rpx;
  212. width: 404rpx;
  213. // 文字垂直居中
  214. font-family: PingFang SC, PingFang SC;
  215. font-weight: 400;
  216. font-size: 28rpx;
  217. padding-top: 10rpx;
  218. color: #333333;
  219. line-height: 40rpx;
  220. text-align: left;
  221. font-style: normal;
  222. text-transform: none;
  223. display: flex;
  224. align-items: center;
  225. span{
  226. font-family: PingFang SC, PingFang SC;
  227. font-weight: 400;
  228. font-size: 24rpx;
  229. color: #C29556;
  230. line-height: 32rpx;
  231. text-align: left;
  232. font-style: normal;
  233. text-transform: none;
  234. }
  235. }
  236. .activity-button {
  237. width: 264rpx;
  238. height: 80rpx;
  239. background: linear-gradient(315deg, #CA9359 0%, #E2B98E 100%);
  240. border-radius: 292rpx 292rpx 292rpx 292rpx;
  241. font-family: PingFang SC, PingFang SC;
  242. font-weight: 400;
  243. font-size: 28rpx;
  244. color: #FFFFFF;
  245. line-height: 36rpx;
  246. text-align: center;
  247. font-style: normal;
  248. text-transform: none;
  249. // 文字垂直居中
  250. display: flex;
  251. align-items: center;
  252. justify-content: center;
  253. }
  254. }
  255. .activity-content-title {
  256. margin: 30rpx auto;
  257. width: 680rpx;
  258. // 垂直居中
  259. font-family: PingFang SC, PingFang SC;
  260. font-weight: 400;
  261. font-size: 32rpx;
  262. color: #333333;
  263. line-height: 40rpx;
  264. text-align: left;
  265. font-style: normal;
  266. text-transform: none;
  267. }
  268. .huodong-ccontent {
  269. position: relative; /* 相对定位 */
  270. width: 650rpx;
  271. padding: 0rpx;
  272. margin: 30rpx auto;
  273. margin-bottom: 0;
  274. padding: 30rpx;
  275. background: #FFFFFF;
  276. border-radius: 16rpx 16rpx 16rpx 16rpx;
  277. display: flex;
  278. align-items: center;
  279. .activity-content {
  280. margin: 30rpx 0rpx 0rpx 30rpx;
  281. .activity-title {
  282. font-family: PingFang SC, PingFang SC;
  283. font-weight: 400;
  284. font-size: 28rpx;
  285. color: #333333;
  286. line-height: 40rpx;
  287. text-align: left;
  288. font-style: normal;
  289. text-transform: none;
  290. font-weight: bold;
  291. margin-bottom: 10rpx;
  292. }
  293. .activity-date {
  294. font-weight: 400;
  295. font-size: 24rpx;
  296. color: #666666;
  297. line-height: 36rpx;
  298. text-align: left;
  299. font-style: normal;
  300. text-transform: none;
  301. margin-bottom: 10rpx;
  302. display: flex;
  303. align-items: center;
  304. }
  305. .activity-price {
  306. height: 44rpx;
  307. font-weight: 400;
  308. font-size: 22rpx;
  309. color: #666666;
  310. line-height: 40rpx;
  311. text-align: left;
  312. font-style: normal;
  313. text-transform: none;
  314. margin-bottom: 24rpx;
  315. display: flex;
  316. align-items: center;
  317. }
  318. }
  319. }
  320. </style>