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

66 lines
1.7 KiB

  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. </view>
  24. </template>
  25. <script setup>
  26. import {useMixin} from "@/utils/useMixin";
  27. import {ref} from "vue";
  28. const {questions} = useMixin()
  29. const radioValue = ref([])
  30. const handleSubmit = (e) => {
  31. wx.login({
  32. success: res => {
  33. if (res.code) {
  34. // 发起网络请求,将 code 发送到服务器进行登录
  35. wx.request({
  36. url: 'https://yourserver.com/getPhoneNumber', // 替换为你的服务器地址
  37. method: 'POST',
  38. data: {
  39. code: res.code,
  40. encryptedData: e.detail.encryptedData,
  41. iv: e.detail.iv
  42. },
  43. success: function(response) {
  44. // 服务器返回解密后的手机号
  45. console.log(response.data.phoneNumber);
  46. }
  47. });
  48. } else {
  49. console.log('登录失败!' + res.errMsg);
  50. }
  51. }
  52. });
  53. }
  54. </script>
  55. <style>
  56. .container {
  57. padding: 20px;
  58. font-size: 14px;
  59. line-height: 24px;
  60. background: #FFFFFF;
  61. }
  62. </style>