123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244 |
- <template>
- <view class="box">
- <view class="main">
- <view class="phoneListBox">
- <view class="phoneLine">
- <view class="phoneLeft">
- 姓名:
- </view>
- <view>
- <input type="text" value="" placeholder-style="color:#999999" placeholder="请输入" class="lineInput" v-model="name"/>
- </view>
- </view>
- <view class="phoneLine">
- <view class="phoneLeft">
- 手机号:
- </view>
- <view>
- <input type="text" value="" placeholder-style="color:#999999" placeholder="请输入" class="lineInput" v-model="phone"/>
- </view>
- </view>
- <view class="phoneLine2" style="display: flex;justify-content: space-between;">
- <view class="DefaultTxt">设为默认联系人</view>
- <view class="lineRight">
- <switch :checked="isDefault" @change="Default" color="#FF4F00" style="transform:scale(0.9)"/>
- </view>
- </view>
- <view class="phoneLine3" @click="delPhone" v-if="id">
- 删除该联系人
- </view>
- </view>
-
- <view class="submit" @click="submit">保存</view>
-
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- name:'',
- phone:'',
- id:'',
- isDefault:true,
- item:'',
- isDefaultNum:0,
- }
- },
- onLoad(opt) {
- //console.log(opt)
- this.item=JSON.parse(opt.item)
- console.log(this.item)
- if(this.item){
- this.name=this.item.name;
- this.phone=this.item.phone;
- this.id=this.item.id;
- if(this.item.isDefault==1){
- this.isDefault=true
- }else{
- this.isDefault=false
- }
-
- }
- },
- onShow() {
-
- },
- methods: {
- Default(e){
- //console.log(e)
- this.isDefault=e.detail.value
- console.log(this.isDefault)
- },
- delPhone(){
- var that=this;
- uni.showModal({
- title: '提示',
- content: '确定要删除联系人吗',
- success: function (res) {
- if (res.confirm) {
- uni.showLoading({
- title: '删除中'
- })
- that.$http('worldKeepCar/keepCarMy/deleteTMemberContact', {
- id:that.id
- },'POST').then(res => {
- uni.hideLoading();
- if(res.code==0){
- uni.navigateBack({
- delta:1
- })
- }
-
- })
- } else if (res.cancel) {
-
- }
- }
- });
- },
- submit(){
- uni.showLoading({
- title: '保存中'
- })
- var isDefault=0;
- if(this.name==''){
- uni.showToast({
- title: '请输入姓名',
- icon:"none",
- duration: 2000
- });
- return false;
- }else if(this.phone.length !=11){
- uni.showToast({
- title: '请输入正确手机号',
- icon:"none",
- duration: 2000
- });
- return false;
- }
- if(this.isDefault){
- this.isDefaultNum=1;
- }
- if(this.id){
- this.edit()
- }else{
- this.add()
- }
-
- },
- add(){
- this.$http('worldKeepCar/keepCarMy/addOrEditTMemberContact', {
- name:this.name,
- phone:this.phone,
- isDefault:this.isDefaultNum,
- },'POST').then(res => {
- uni.hideLoading();
- if(res.code!=0){
- uni.showModal({
- title: '提示',
- content: res.msg,
- success: function (res) {
-
- }
- })
- }else{
- uni.navigateBack({
- delta:1
- })
- }
- })
- },
- edit(){
- this.$http('worldKeepCar/keepCarMy/addOrEditTMemberContact', {
- name:this.name,
- phone:this.phone,
- isDefault:this.isDefaultNum,
- id:this.id,
- },'POST').then(res => {
- uni.hideLoading();
- if(res.code!=0){
- uni.showModal({
- title: '提示',
- content: res.msg,
- success: function (res) {
-
- }
- })
- }else{
- uni.navigateBack({
- delta:1
- })
- }
- })
- },
-
- login(){
- uni.navigateTo({
- url:'../login/login'
- })
- }
- }
- }
- </script>
- <style scoped>
- .box{
- min-height: 100vh;
- background:#F4F5F7 ;
- }
- .main{
- padding: 24rpx;
-
- }
- .phoneListBox{
- background: #FFFFFF;
- border-radius: 10rpx;
- padding: 0 24rpx;
- }
- .phoneLine{
- display: flex;
-
- padding: 30rpx;
- border-bottom: 1px #EEEEEE solid;
- }
- .phoneLeft{
- width: 150rpx;font-size: 28rpx;
- color: #3C3C3C;
- }
- .phoneLine2{
- padding:20rpx 30rpx;border-bottom: 1px solid #EEEEEE;
- }
- .lineInput{
- color: #333333;
- font-size: 28rpx;
- }
- .DefaultTxt{
- font-size: 28rpx;
- color: #3C3C3C;
- display: flex;
- align-items: center;
- }
- .submit{
- width: 690rpx;
- height: 74rpx;
- background: linear-gradient(124deg, #FF8700 0%, #FF4F00 100%);
- border-radius: 37rpx;
- line-height: 74rpx;
- text-align: center;
- color: #FFFFFF;
- font-size: 30rpx;
- margin-top: 80rpx;
- margin-left: 6rpx;
- }
- .phoneLine3{
- color: #FF3B30;
- font-size: 26rpx;
- padding: 30rpx;
- }
- </style>
|