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

<template>
<view class="container">
<view v-for="(item,index) in questions" :key="index">
<view>{{ item.name }}</view>
<up-radio-group
v-model="radioValue[index]"
placement="column"
iconPlacement="right"
>
<up-radio
:customStyle="{marginBottom: '8px'}"
v-for="(item, index) in item.option"
:key="index"
:label="item.name"
:name="item.value"
@change="radioChange"
>
</up-radio>
</up-radio-group>
</view>
<up-button text="提交1" open-type="getPhoneNumber"
@getphonenumber="handleSubmit"></up-button>
</view>
</template>
<script setup>
import {useMixin} from "@/utils/useMixin";
import {ref} from "vue";
const {questions} = useMixin()
const radioValue = ref([])
const handleSubmit = (e) => {
wx.login({
success: res => {
if (res.code) {
// 发起网络请求,将 code 发送到服务器进行登录
wx.request({
url: 'https://yourserver.com/getPhoneNumber', // 替换为你的服务器地址
method: 'POST',
data: {
code: res.code,
encryptedData: e.detail.encryptedData,
iv: e.detail.iv
},
success: function(response) {
// 服务器返回解密后的手机号
console.log(response.data.phoneNumber);
}
});
} else {
console.log('登录失败!' + res.errMsg);
}
}
});
}
</script>
<style>
.container {
padding: 20px;
font-size: 14px;
line-height: 24px;
background: #FFFFFF;
}
</style>