兼兼街公众号代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

266 lines
5.9 KiB

  1. <template>
  2. <view class="buy-course">
  3. <view class="course-box ">
  4. <view class="course-box-item flex">
  5. <u--image :showLoading="true" :src="dataInfo.photo" width="281rpx" height="178rpx"></u--image>
  6. <view class="box-right">
  7. <view class="active-title">{{dataInfo.title}}[{{dataInfo.money}}/小时]</view>
  8. <view class="active-time">
  9. <text>{{dataInfo.startTime}} - {{dataInfo.endTime}}</text>
  10. </view>
  11. <view class="active-add">
  12. <text>{{dataInfo.place}}</text>
  13. </view>
  14. </view>
  15. </view>
  16. </view>
  17. <view class="from-box">
  18. <view class="from-title">填写报名人信息</view>
  19. <u--form
  20. labelPosition="left"
  21. :model="userInfo"
  22. ref="form1"
  23. labelWidth="80"
  24. :labelStyle="formLabelStyle"
  25. >
  26. <u-form-item
  27. label="姓名:"
  28. borderBottom
  29. ref="item1"
  30. >
  31. <u--input
  32. v-model="userInfo.name"
  33. border="none"
  34. placeholder="请输入姓名"
  35. ></u--input>
  36. </u-form-item>
  37. <u-form-item
  38. label="联系电话:"
  39. borderBottom
  40. ref="item1"
  41. >
  42. <u--input
  43. v-model="userInfo.phone"
  44. border="none"
  45. placeholder="请输入手机号码"
  46. type="number"
  47. ></u--input>
  48. </u-form-item>
  49. </u--form>
  50. </view>
  51. <view class="pay-box">
  52. <view class="pay-price flex align-center justify-between">
  53. <view class="pay-price-tip">费用</view>
  54. <view>
  55. <text class="unit"></text>
  56. <text>{{dataInfo.price}}</text>
  57. </view>
  58. </view>
  59. <view class="pay-type">
  60. <view class="pay-type-item flex justify-between align-center" v-for="item in payList" :key="item.id" @click="choosePay(item)">
  61. <view class="flex align-center">
  62. <image class="type-img" :src="item.src" mode=""></image>
  63. <text class="ml-1">{{item.text}}</text>
  64. </view>
  65. <image class="choose-img" :src="chooseType == item.id? '../../static/img/choose-act.png' : '../../static/img/choose.png'" mode=""></image>
  66. </view>
  67. </view>
  68. </view>
  69. <view class="btn-box">
  70. <u-button text="立即报名" @click="apply" :customStyle="baomingStyle" :hairline="false" color="#00BBFF"></u-button>
  71. </view>
  72. </view>
  73. </template>
  74. <script>
  75. export default{
  76. data(){
  77. return{
  78. chooseType: 0,
  79. id:'',
  80. dataInfo: {},
  81. userInfo:{
  82. name:'',
  83. companyName:'',
  84. phone:'',
  85. companyPost:''
  86. },
  87. formLabelStyle:{
  88. color: '#707070',
  89. fontSize: '30rpx'
  90. },
  91. baomingStyle: {
  92. fontSize:"30rpx",
  93. fontWeight:"700",
  94. height: "100rpx"
  95. },
  96. payList: [
  97. {
  98. id:0,
  99. text:'微信支付',
  100. src:require('@/static/img/wechat-icon.png')
  101. },
  102. ]
  103. }
  104. },
  105. // 隐藏微信h5的标题栏
  106. onReady() {
  107. this.$com.displayNav()
  108. },
  109. onLoad(e) {
  110. this.getactivityFindById(e.id);
  111. this.id = e.id;
  112. },
  113. methods:{
  114. choosePay(item){
  115. this.chooseType = item.id;
  116. },
  117. apply(){//添加报名信息
  118. if(this.userInfo.phone.length != 11){
  119. this.$Toast('请输入正确手机号!')
  120. return
  121. }
  122. let params = {
  123. activityId:this.id,
  124. payType:this.chooseType,
  125. ...this.userInfo,
  126. }
  127. this.$api('saveEnroll',params)
  128. .then(res=>{
  129. if(res.code == 200){
  130. this.wxPay(res.result)
  131. }else{
  132. this.$Toast(res.message)
  133. }
  134. })
  135. },
  136. wxPay(id){
  137. let that = this;
  138. that.$api('create',{id})
  139. .then(res=>{
  140. that.$jweixin.chooseWXPay({
  141. appId: res.result.appId,
  142. timestamp: res.result.timeStamp, // 支付签名时间戳,注意微信 jssdk 中的所有使用 timestamp 字段均为小写。但最新版的支付后台生成签名使用的 timeStamp 字段名需大写其中的 S 字符
  143. nonceStr: res.result.nonceStr, // 支付签名随机串,不长于 32 位
  144. package: res.result.packageValue, // 统一支付接口返回的prepay_id参数值,提交格式如:prepay_id=\*\*\*)
  145. signType: res.result.signType, // 微信支付V3的传入 RSA ,微信支付V2的传入格式与V2统一下单的签名格式保持一致
  146. paySign: res.result.paySign, // 支付签名
  147. success: function (res) {
  148. // 支付成功后的回调函数
  149. }
  150. });
  151. })
  152. },
  153. getactivityFindById(id){
  154. uni.showLoading()
  155. this.$api('activityFindById',{id})
  156. .then(res=>{
  157. uni.hideLoading()
  158. if(res.code == 200){
  159. this.dataInfo = res.result;
  160. }
  161. })
  162. }
  163. }
  164. }
  165. </script>
  166. <style lang="scss" scoped>
  167. .buy-course {
  168. .course-box {
  169. padding: 0 26rpx;
  170. .course-box-item {
  171. background: #ffffff;
  172. border-radius: 12rpx;
  173. box-shadow: 3rpx 3rpx 6rpx 3rpx rgba(0,0,0,0.16);
  174. padding: 33rpx 13rpx;
  175. .box-right {
  176. margin-left: 16rpx;
  177. .active-title {
  178. font-size: 30rpx;
  179. color: #000;
  180. line-height: 40rpx;
  181. overflow: hidden;
  182. display: -webkit-box;
  183. -webkit-box-orient: vertical;
  184. -webkit-line-clamp: 2;
  185. }
  186. .active-time {
  187. color: #707070;
  188. font-size: 26rpx;
  189. margin: 10rpx 0 14rpx 0;
  190. }
  191. .active-add {
  192. color: #707070;
  193. font-size: 26rpx;
  194. }
  195. }
  196. }
  197. }
  198. .from-box {
  199. padding: 0 26rpx;
  200. .from-title {
  201. font-size: 30rpx;
  202. color: #000;
  203. margin-top: 35rpx;
  204. margin-bottom: 15rpx;
  205. }
  206. }
  207. .pay-box {
  208. border-top: 20rpx solid #F5F5F5;
  209. padding: 0 26rpx;
  210. .pay-price {
  211. color: #D33D3E;
  212. font-size: 40rpx;
  213. font-weight: 700;
  214. padding: 47rpx 0 20rpx 0;
  215. border-bottom: 1px solid #E6E6E6;
  216. .pay-price-tip {
  217. color: #000000;
  218. font-size: 30rpx;
  219. font-weight: 400;
  220. }
  221. .unit {
  222. font-size: 30rpx;
  223. font-weight: 400;
  224. }
  225. }
  226. .pay-type {
  227. padding-top: 22rpx;
  228. .pay-type-item {
  229. margin-bottom: 42rpx;
  230. .type-img {
  231. width: 70rpx;
  232. height: 70rpx;
  233. }
  234. .choose-img {
  235. width: 46rpx;
  236. height: 46rpx;
  237. }
  238. }
  239. }
  240. }
  241. .btn-box {
  242. position: fixed;
  243. bottom: 0;
  244. left: 0;
  245. right: 0;
  246. }
  247. }
  248. </style>