猫妈狗爸伴宠师小程序前端代码
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.

68 lines
1.7 KiB

2 weeks ago
  1. <template>
  2. <view class="container">
  3. <view v-for="(item,index) in questions" :key="index">
  4. <view>{{ item.name }}</view>
  5. <up-radio-group
  6. v-model="radioValue[index]"
  7. placement="column"
  8. iconPlacement="right"
  9. >
  10. <up-radio
  11. :customStyle="{marginBottom: '8px'}"
  12. v-for="(item, index) in item.option"
  13. :key="index"
  14. :label="item.name"
  15. :name="item.value"
  16. @change="radioChange"
  17. >
  18. </up-radio>
  19. </up-radio-group>
  20. </view>
  21. <up-button text="提交1" open-type="getPhoneNumber"
  22. @getphonenumber="handleSubmit"></up-button>
  23. <!-- 客服组件 -->
  24. <CustomerService />
  25. </view>
  26. </template>
  27. <script setup>
  28. import {useMixin} from "@/utils/useMixin";
  29. import {ref} from "vue";
  30. const {questions} = useMixin()
  31. const radioValue = ref([])
  32. const handleSubmit = (e) => {
  33. wx.login({
  34. success: res => {
  35. if (res.code) {
  36. // 发起网络请求,将 code 发送到服务器进行登录
  37. wx.request({
  38. url: 'https://yourserver.com/getPhoneNumber', // 替换为你的服务器地址
  39. method: 'POST',
  40. data: {
  41. code: res.code,
  42. encryptedData: e.detail.encryptedData,
  43. iv: e.detail.iv
  44. },
  45. success: function(response) {
  46. // 服务器返回解密后的手机号
  47. console.log(response.data.phoneNumber);
  48. }
  49. });
  50. } else {
  51. console.log('登录失败!' + res.errMsg);
  52. }
  53. }
  54. });
  55. }
  56. </script>
  57. <style>
  58. .container {
  59. padding: 20px;
  60. font-size: 14px;
  61. line-height: 24px;
  62. background: #FFFFFF;
  63. }
  64. </style>