sendAddress.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. const util = require('../../../utils/util.js');
  2. Component({
  3. properties: {
  4. theam:{
  5. type: String,
  6. value:'redContent',
  7. observer: function (newVal) {
  8. this.setData({ theam: newVal });
  9. }
  10. },
  11. prizeId:{
  12. type: String,
  13. observer: function (newVal) {
  14. this.setData({ id: newVal });
  15. }
  16. },
  17. show:{
  18. type: Boolean,
  19. observer: function (val){
  20. this.setData({ show: val });
  21. if (val) {this.getFormData()}
  22. }
  23. },
  24. },
  25. data: {
  26. id:'',
  27. show:false,
  28. height:'60%',
  29. theam:'redContent',
  30. provincial:'',
  31. address:'',
  32. info:{
  33. region: ['浙江省', '杭州市', '上城区']
  34. }
  35. },
  36. methods: {
  37. bindRegionChange(e) {
  38. let value = e.detail.value, provincial = this.data.provincial;
  39. if (value){
  40. provincial=value.join('/')
  41. }
  42. this.setData({ 'info.region':provincial });
  43. },
  44. save(e){
  45. let data = e.detail.value,that=this;
  46. if (util.isEmpty(data.contactName)) {
  47. util.showTips('姓名不能为空');
  48. return false;
  49. }
  50. if (util.isEmpty(data.contactPhone)) {
  51. util.showTips('手机号不能为空');
  52. return false;
  53. }
  54. if (util.isPhone(data.contactPhone)) {
  55. util.showTips('请正确填写手机号');;
  56. return false;
  57. }
  58. if (util.isEmpty(data.provincial)) {
  59. util.showTips('省市区不能为空');
  60. return false;
  61. }
  62. if (util.isEmpty(data.address)) {
  63. util.showTips('详细地址不能为空');
  64. return false;
  65. }
  66. let arr =[];
  67. arr.push(data.provincial)
  68. arr.push(data.address)
  69. data.mailAddress = arr.join(' ');
  70. data.id = this.data.id;
  71. util.ajax({
  72. func: "v2/market/wheel/record/change/mailAddress",
  73. method:'post',
  74. data: data
  75. }, function (res) {
  76. if (res.code==0) {
  77. util.showTips(res.reason)
  78. setTimeout(() => {
  79. that.closePopup()
  80. }, 500);
  81. } else {util.showTips(res.reason)}
  82. })
  83. },
  84. // 获取表单数据
  85. getFormData(){
  86. let that = this;
  87. util.ajax({
  88. func: "v2/market/wheel/record/mailAddress",
  89. data: {id:this.data.id}
  90. }, function (res) {
  91. if (res.code==0) {
  92. let data = res.data;
  93. let region = data.mailAddress.split(' ')[0]
  94. data.region = region.split('/');
  95. data.address = data.mailAddress.split(' ')[1]
  96. that.setData({info:data})
  97. } else {util.showTips(res.reason)}
  98. })
  99. },
  100. // 关闭弹窗
  101. closeTip(e){
  102. this.close(e.detail)
  103. },
  104. // 确定
  105. closePopup(){
  106. this.close(false)
  107. },
  108. close(data){
  109. this.triggerEvent("close", {
  110. status:data,
  111. type:'address'
  112. });
  113. }
  114. }
  115. })