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.

243 lines
7.0 KiB

  1. <template>
  2. <view class="content">
  3. <img src="/static/logo.png" style="position: absolute;right: 10px;top: 10px;" height="25rpx"/>
  4. <img :src="item" width="100%" v-for="(item, index) in list"/>
  5. <view class="bottom">
  6. <view class="shang" style="padding-bottom: 200rpx;">
  7. <view class="info"
  8. style="color: #fff;margin-bottom: 40rpx;">
  9. 填写信息立即报名
  10. </view>
  11. <div class="register-username">
  12. <!-- <image src='../../static/register/userNameLogin@3x.png'></image> -->
  13. <u--input placeholder="请输入学生姓名" border="surround"
  14. v-model="registerForm.name"></u--input>
  15. </div>
  16. <div class="register-username">
  17. <!-- <image src='../../static/register/userNameLogin@3x.png'></image> -->
  18. <u--input placeholder="请输入手机号" border="surround"
  19. v-model="registerForm.phone"></u--input>
  20. </div>
  21. <view style="margin-bottom: 20rpx;">
  22. <text style="color: #fff;font-size: 40rpx;
  23. margin-right: 10rpx;">{{ price }}</text>
  24. <del style="color: #eee;font-size: 28rpx;">原价300.0</del>
  25. </view>
  26. <u-button type="primary" @click="Register()"
  27. style="border-radius: 20rpx;color: #000;width: 200rpx;"
  28. color="#fff">立即支付</u-button>
  29. <!-- <view style="color: #ccc;font-size: 35rpx;margin-top: 50rpx;display: flex;
  30. justify-content: center;flex-direction: column;align-items: center;">
  31. <img src="/static/d01.png" style="" width="200rpx"/>
  32. <img src="/static/logo.png" style="" width="100rpx"/>
  33. 冠尚彤语言训练系统
  34. </view> -->
  35. <view style="color: rgb(238 234 56);font-size: 33rpx;margin-top: 460rpx;display: flex;
  36. justify-content: center;align-items: center;font-weight: 900;">
  37. <img src="/static/d01.png" style="margin-right: 10rpx;" height="28rpx"/>
  38. <view style="position: relative;">
  39. <view style="color: #fff;font-size: 25rpx;
  40. position: absolute;top: -390rpx;white-space:nowrap;
  41. display: flex;flex-direction: column;
  42. justify-content: center;align-items: center;
  43. " @click="clickService">
  44. 联系我们{{ phone }}
  45. <view style="margin-top: 20rpx;text-align: center;">
  46. 预约请扫码<br />
  47. <img src="/static/er3.png" width="145rpx"/>
  48. </view>
  49. </view>
  50. 冠尚彤语言训练系统
  51. </view>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. </template>
  57. <script>
  58. import api from '@/plugins/api.js'
  59. export default {
  60. data() {
  61. return {
  62. code : '',
  63. price : 0,
  64. registerForm: {
  65. name: '',
  66. phone: '',
  67. },
  68. type : 1,//0是money,1是price
  69. phone : '400-026-7262',
  70. list : [
  71. '/static/0240718173256.jpg',
  72. '/static/24.png',
  73. '/static/123.png',
  74. ]
  75. }
  76. },
  77. onLoad() {
  78. if(this.GetQueryString('code')){ //路径上面有code说明微信已授权
  79. this.code = this.GetQueryString('code');
  80. //直接去登录发起请求
  81. this.toWxLogin(this.code)
  82. }else{
  83. this.getwx_authorize()
  84. }
  85. },
  86. methods: {
  87. getwx_authorize() {
  88. // let vid = uni.getStorageSync("ivcode");
  89. let redirect_uri = encodeURIComponent(this.VITE_REDIRECT_URI);
  90. let appid = this.VITE_APPID;
  91. window.location.href="https://open.weixin.qq.com/connect/oauth2/authorize?appid="+appid+'&redirect_uri='+redirect_uri+'&response_type=code&scope=snsapi_userinfo&state=123#wechat_redirect'+'&t='+new Date().getTime();
  92. },
  93. //获取url中参数的方法
  94. GetQueryString(name) {
  95. var url = window.location.href;
  96. try {
  97. var cs = url.split('?')[1]; //获取?之后的参数字符串
  98. var cs_arr = cs.split('&'); //参数字符串分割为数组
  99. for (var i = 0; i < cs_arr.length; i++) { //遍历数组,拿到json对象
  100. if (cs_arr[i].split('=')[0] == name) {
  101. return cs_arr[i].split('=')[1];
  102. }
  103. }
  104. return "";
  105. } catch {
  106. return "";
  107. }
  108. },
  109. clickService() {
  110. uni.makePhoneCall({
  111. phoneNumber: this.phone,
  112. success: () => {},
  113. fail: () => {}
  114. });
  115. },
  116. //微信登录
  117. toWxLogin(code) {
  118. console.log(code);
  119. api('wxLogin', { code }, res=>{
  120. if(res.code == 200){
  121. if(this.type == 0){
  122. this.price = res.result.money
  123. }else{
  124. this.price = res.result.price
  125. }
  126. localStorage.setItem("token", res.result.token)
  127. localStorage.setItem("userInfo", JSON.stringify(res.result.userInfo))
  128. }else{
  129. location.href = this.VITE_REDIRECT_URI
  130. }
  131. })
  132. },
  133. Register(){
  134. if(!localStorage.getItem('token')){
  135. this.getwx_authorize()
  136. }
  137. if (this.registerForm.name.trim() === '') return uni.$u.toast('请输入姓名')
  138. else if (this.registerForm.phone.trim() === '') return uni.$u.toast('请输入手机号')
  139. if(!/^1[3-9]\d{9}$/.test(this.registerForm.phone)){
  140. return uni.$u.toast('手机号格式不合法')
  141. }
  142. api('createOrder', {
  143. ...this.registerForm,
  144. type : this.type
  145. }, res=>{
  146. if(res.code == 200){
  147. this.chooseWXPay(res.result)
  148. }
  149. })
  150. },
  151. chooseWXPay(res){
  152. let self = this
  153. self.$jweixin.config({
  154. debug: false,
  155. appId:res.appId,//必填
  156. jsApiList: ['chooseWXPay']
  157. });
  158. self.$jweixin.ready(function() {
  159. self.$jweixin.chooseWXPay({
  160. appId: res.appId,
  161. timestamp: res
  162. .timeStamp, // 支付签名时间戳,注意微信 jssdk 中的所有使用 timestamp 字段均为小写。但最新版的支付后台生成签名使用的 timeStamp 字段名需大写其中的 S 字符
  163. nonceStr: res.nonceStr, // 支付签名随机串,不长于 32 位
  164. package: res.packageValue, // 统一支付接口返回的prepay_id参数值,提交格式如:prepay_id=\*\*\*)
  165. signType: res.signType, // 微信支付V3的传入 RSA ,微信支付V2的传入格式与V2统一下单的签名格式保持一致
  166. paySign: res.paySign, // 支付签名
  167. success: function(res) {
  168. // 支付成功后的回调函数
  169. uni.showToast({
  170. icon: 'none',
  171. title: '支付成功',
  172. });
  173. self.registerForm.name = ''
  174. self.registerForm.phone = ''
  175. }
  176. });
  177. });
  178. self.$jweixin.error(function(res) {
  179. uni.showToast({
  180. icon: 'none',
  181. title: '支付失败了',
  182. });
  183. });
  184. },
  185. }
  186. }
  187. </script>
  188. <style scoped lang="scss">
  189. .content {
  190. display: flex;
  191. flex-direction: column;
  192. align-items: center;
  193. }
  194. .bottom{
  195. display: flex;
  196. flex-direction: column;
  197. align-items: center;
  198. position: relative;
  199. width: 100%;
  200. // --color : #890404;
  201. --color : #dc2808;
  202. .shang{
  203. width: 100%;
  204. box-sizing: border-box;
  205. background: linear-gradient(to right, rgb(239,118,66), rgb(220, 38, 7));
  206. overflow: hidden;
  207. padding: 30rpx 0;
  208. display: flex;
  209. flex-direction: column;
  210. justify-content: center;
  211. align-items: center;
  212. }
  213. }
  214. .register-username{
  215. display: flex;
  216. border: 1px solid #ED762F;
  217. height: 35px;
  218. align-items: center;
  219. margin-bottom: 20px;
  220. padding: 0 10px;
  221. border-radius: 5px;
  222. box-sizing: border-box;
  223. background-color: #fff;
  224. color: #000;
  225. image {
  226. width: 20px;
  227. height: 20px;
  228. }
  229. }
  230. </style>