Browse Source

绑定手机号

master
kuaileWu 3 months ago
parent
commit
2c87374500
  1. 18
      components/FormItem.vue
  2. 17
      components/SelectYear.vue
  3. 4
      main.js
  4. 40
      pages/index/index.vue
  5. 2
      pages/modify_visitor/modify_visitor.vue

18
components/FormItem.vue

@ -6,7 +6,7 @@
<text>{{ label }}</text> <text>{{ label }}</text>
<image v-if="required" class="required" :src="cssUrl + 'required.svg'" /> <image v-if="required" class="required" :src="cssUrl + 'required.svg'" />
</view> </view>
<!-- 输入模式 --> <!-- 输入模式 -->
<input <input
v-if="type === 'input'" v-if="type === 'input'"
@ -16,7 +16,7 @@
@input="handleInput" @input="handleInput"
:disabled="disabled" :disabled="disabled"
/> />
<!-- 点击选择模式如性别年份 --> <!-- 点击选择模式如性别年份 -->
<view <view
v-else v-else
@ -32,7 +32,7 @@
</view> </view>
</view> </view>
</template> </template>
<script> <script>
export default { export default {
name: 'FormItem', name: 'FormItem',
@ -51,7 +51,7 @@
}, },
data(){ data(){
return{ return{
cssUrl: this.cssUrl, cssUrl: this.cssUrl,
} }
}, },
methods: { methods: {
@ -66,7 +66,7 @@
}, },
}; };
</script> </script>
<style scoped> <style scoped>
.form-item { .form-item {
display: flex; display: flex;
@ -79,7 +79,7 @@
width: 26rpx; width: 26rpx;
height: 26rpx; height: 26rpx;
} }
.label { .label {
display: flex; display: flex;
align-items: center; align-items: center;
@ -90,7 +90,7 @@
letter-spacing: 2rpx; letter-spacing: 2rpx;
color: #222222; color: #222222;
} }
.required { .required {
margin-left: 8rpx; margin-left: 8rpx;
color: #f56c6c; color: #f56c6c;
@ -98,7 +98,7 @@
width: 16rpx; width: 16rpx;
height: 16rpx; height: 16rpx;
} }
.input, .input,
.picker { .picker {
flex: 1; flex: 1;
@ -106,7 +106,7 @@
padding-left: 20rpx; padding-left: 20rpx;
color: #333; color: #333;
} }
.placeholder { .placeholder {
font-family: PingFang SC; font-family: PingFang SC;
font-size: 32rpx; font-size: 32rpx;

17
components/SelectYear.vue

@ -28,15 +28,16 @@
export default { export default {
data() { data() {
const date = new Date() const date = new Date()
const years = [] const years = []
const year = date.getFullYear() const year = date.getFullYear()
for (let i = 1990; i <= date.getFullYear(); i++) { for (let i = 1900; i <= date.getFullYear(); i++) {
years.push(i) years.push(i)
} }
return { return {
cssUrl:this.cssUrl, cssUrl:this.cssUrl,
years: years, // value:[90],
currentYear: new Date().getFullYear(), currentYear: 1990,
years: years,
}; };
}, },
methods: { methods: {
@ -51,7 +52,7 @@ export default {
this.$refs.selectDate.open('bottom') this.$refs.selectDate.open('bottom')
}, },
closePop() { closePop() {
this.$refs.selectDate.close() this.$refs.selectDate.close()
}, },
}, },
}; };

4
main.js

@ -152,8 +152,8 @@ try{
Vue.prototype.isMobile = isMobile(); Vue.prototype.isMobile = isMobile();
} }
const NODE_ENV = 'development'; // const NODE_ENV = 'development';
// const NODE_ENV = 'production'; const NODE_ENV = 'production';
if(Vue.prototype.provider == Vue.prototype.provider_weixin){ if(Vue.prototype.provider == Vue.prototype.provider_weixin){
if (NODE_ENV == "development") { if (NODE_ENV == "development") {
Vue.prototype.request_domain = 'http://jasonyizherenxin.checkcopy.com/'; Vue.prototype.request_domain = 'http://jasonyizherenxin.checkcopy.com/';

40
pages/index/index.vue

@ -113,7 +113,7 @@
</view> </view>
</view> </view>
</uni-popup> </uni-popup>
<button class="getphone-box" open-type="getPhoneNumber" bindgetphonenumber="onGetPhoneNumber" v-if="!doctorInfo.aid"></button> <button class="getphone-box" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber" v-if="!doctorInfo.aid"></button>
</view> </view>
</template> </template>
@ -160,12 +160,6 @@ export default {
this.state = option.state this.state = option.state
} }
}, },
onReady() { // 使 onReady onLoad
// #ifdef MP-WEIXIN
// this.triggerGetPhone();
// #endif
},
async onShow() { async onShow() {
this.doctor_id = getApp().globalData.doctorId this.doctor_id = getApp().globalData.doctorId
if (!this.doctor_id) return if (!this.doctor_id) return
@ -196,42 +190,18 @@ export default {
this.$refs.nameWrap.close() this.$refs.nameWrap.close()
}); });
}, },
// getPhoneNumber(e) {
triggerGetPhone() { console.log(e)
//
setTimeout(() => {
const query = uni.createSelectorQuery().in(this);
query.select('#getPhoneBtn')
.node()
.exec((res) => {
const node = res[0]?.node;
if (node) {
node.dispatchEvent(new CustomEvent('tap'));
} else {
console.error('节点未找到,请检查:', res);
//
wx.showModal({
title: '提示',
content: '请手动点击授权按钮',
});
}
});
}, 800);
},
//
onGetPhoneNumber(e) {
if (e.detail.errMsg === 'getPhoneNumber:ok') { if (e.detail.errMsg === 'getPhoneNumber:ok') {
console.log(e.detail.code)
this.$http.req('api/user/bind_phone', {phonecode:e.detail.code}, 'POST').then(data=>{ this.$http.req('api/user/bind_phone', {phonecode:e.detail.code}, 'POST').then(data=>{
if(data == -1) return if(data == -1) return
this.getDoctorInfo()
}); });
} else { } else {
} }
}, },
toLocation(hospital) { toLocation(hospital) {
// #ifdef MP-WEIXIN // #ifdef MP-WEIXIN
var lngLat = hospital.hospital_pos.toString().split(',') var lngLat = hospital.hospital_pos.toString().split(',')
var lng = Number(lngLat[1]) var lng = Number(lngLat[1])
@ -320,7 +290,7 @@ export default {
this.doctorInfo = data; this.doctorInfo = data;
this.user_type = this.doctorInfo.user_type; this.user_type = this.doctorInfo.user_type;
if(!data.realname) { if(!data.realname && data.aid) {
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.nameWrap.open('bottom') this.$refs.nameWrap.open('bottom')
}) })

2
pages/modify_visitor/modify_visitor.vue

@ -178,7 +178,7 @@ export default {
// }, // },
checkSubmit() { checkSubmit() {
this.canSubmit = false this.canSubmit = false
if (!this.name || !this.sex || !this.year) return if (!this.name || (this.sex !=0 && this.sex!=1) || !this.year) return
this.canSubmit = true this.canSubmit = true
}, },
reback() { reback() {

Loading…
Cancel
Save