addphone.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. <template>
  2. <view class="box">
  3. <view class="main">
  4. <view class="phoneListBox">
  5. <view class="phoneLine">
  6. <view class="phoneLeft">
  7. 姓名:
  8. </view>
  9. <view>
  10. <input type="text" value="" placeholder-style="color:#999999" placeholder="请输入" class="lineInput" v-model="name"/>
  11. </view>
  12. </view>
  13. <view class="phoneLine">
  14. <view class="phoneLeft">
  15. 手机号:
  16. </view>
  17. <view>
  18. <input type="text" value="" placeholder-style="color:#999999" placeholder="请输入" class="lineInput" v-model="phone"/>
  19. </view>
  20. </view>
  21. <view class="phoneLine2" style="display: flex;justify-content: space-between;">
  22. <view class="DefaultTxt">设为默认联系人</view>
  23. <view class="lineRight">
  24. <switch :checked="isDefault" @change="Default" color="#FF4F00" style="transform:scale(0.9)"/>
  25. </view>
  26. </view>
  27. <view class="phoneLine3" @click="delPhone" v-if="id">
  28. 删除该联系人
  29. </view>
  30. </view>
  31. <view class="submit" @click="submit">保存</view>
  32. </view>
  33. </view>
  34. </template>
  35. <script>
  36. export default {
  37. data() {
  38. return {
  39. name:'',
  40. phone:'',
  41. id:'',
  42. isDefault:true,
  43. item:'',
  44. isDefaultNum:0,
  45. }
  46. },
  47. onLoad(opt) {
  48. //console.log(opt)
  49. this.item=JSON.parse(opt.item)
  50. console.log(this.item)
  51. if(this.item){
  52. this.name=this.item.name;
  53. this.phone=this.item.phone;
  54. this.id=this.item.id;
  55. if(this.item.isDefault==1){
  56. this.isDefault=true
  57. }else{
  58. this.isDefault=false
  59. }
  60. }
  61. },
  62. onShow() {
  63. },
  64. methods: {
  65. Default(e){
  66. //console.log(e)
  67. this.isDefault=e.detail.value
  68. console.log(this.isDefault)
  69. },
  70. delPhone(){
  71. var that=this;
  72. uni.showModal({
  73. title: '提示',
  74. content: '确定要删除联系人吗',
  75. success: function (res) {
  76. if (res.confirm) {
  77. uni.showLoading({ });
  78. that.$http('worldKeepCar/keepCarMy/deleteTMemberContact', {
  79. id:that.id
  80. },'POST').then(res => {
  81. uni.hideLoading();
  82. if(res.code==0){
  83. uni.navigateBack({
  84. delta:1
  85. })
  86. }
  87. })
  88. } else if (res.cancel) {
  89. }
  90. }
  91. });
  92. },
  93. submit(){
  94. uni.showLoading({ });
  95. var isDefault=0;
  96. if(this.name==''){
  97. uni.showToast({
  98. title: '请输入姓名',
  99. icon:"none",
  100. duration: 2000
  101. });
  102. return false;
  103. }else if(this.phone.length !=11){
  104. uni.showToast({
  105. title: '请输入正确手机号',
  106. icon:"none",
  107. duration: 2000
  108. });
  109. return false;
  110. }
  111. if(this.isDefault){
  112. this.isDefaultNum=1;
  113. }
  114. if(this.id){
  115. this.edit()
  116. }else{
  117. this.add()
  118. }
  119. },
  120. add(){
  121. this.$http('worldKeepCar/keepCarMy/addOrEditTMemberContact', {
  122. name:this.name,
  123. phone:this.phone,
  124. isDefault:this.isDefaultNum,
  125. },'POST').then(res => {
  126. uni.hideLoading();
  127. if(res.code!=0){
  128. uni.showModal({
  129. title: '提示',
  130. content: res.msg,
  131. success: function (res) {
  132. }
  133. })
  134. }else{
  135. uni.navigateBack({
  136. delta:1
  137. })
  138. }
  139. })
  140. },
  141. edit(){
  142. this.$http('worldKeepCar/keepCarMy/addOrEditTMemberContact', {
  143. name:this.name,
  144. phone:this.phone,
  145. isDefault:this.isDefaultNum,
  146. id:this.id,
  147. },'POST').then(res => {
  148. uni.hideLoading();
  149. if(res.code!=0){
  150. uni.showModal({
  151. title: '提示',
  152. content: res.msg,
  153. success: function (res) {
  154. }
  155. })
  156. }else{
  157. uni.navigateBack({
  158. delta:1
  159. })
  160. }
  161. })
  162. },
  163. login(){
  164. uni.navigateTo({
  165. url:'../login/login'
  166. })
  167. }
  168. }
  169. }
  170. </script>
  171. <style scoped>
  172. .box{
  173. min-height: 100vh;
  174. background:#F4F5F7 ;
  175. }
  176. .main{
  177. padding: 24rpx;
  178. }
  179. .phoneListBox{
  180. background: #FFFFFF;
  181. border-radius: 10rpx;
  182. padding: 0 24rpx;
  183. }
  184. .phoneLine{
  185. display: flex;
  186. padding: 30rpx;
  187. border-bottom: 1px #EEEEEE solid;
  188. }
  189. .phoneLeft{
  190. width: 150rpx;font-size: 28rpx;
  191. color: #3C3C3C;
  192. }
  193. .phoneLine2{
  194. padding:20rpx 30rpx;border-bottom: 1px solid #EEEEEE;
  195. }
  196. .lineInput{
  197. color: #333333;
  198. font-size: 28rpx;
  199. }
  200. .DefaultTxt{
  201. font-size: 28rpx;
  202. color: #3C3C3C;
  203. display: flex;
  204. align-items: center;
  205. }
  206. .submit{
  207. width: 690rpx;
  208. height: 74rpx;
  209. background: linear-gradient(124deg, #FF8700 0%, #FF4F00 100%);
  210. border-radius: 37rpx;
  211. line-height: 74rpx;
  212. text-align: center;
  213. color: #FFFFFF;
  214. font-size: 30rpx;
  215. margin-top: 80rpx;
  216. margin-left: 6rpx;
  217. }
  218. .phoneLine3{
  219. color: #FF3B30;
  220. font-size: 26rpx;
  221. padding: 30rpx;
  222. }
  223. </style>