1
0

scheme.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. // miniprogram/scheme/scheme.js
  2. const app=getApp();
  3. const utils=require("../../utils/http");
  4. let time1=null;
  5. Component({
  6. /**
  7. * 组件的属性列表
  8. */
  9. properties: {
  10. priceflag:{
  11. type: Boolean,
  12. value:false
  13. },
  14. rType: {
  15. type: String,
  16. value: ''
  17. },
  18. curId: {
  19. type: String|Number,
  20. value: ''
  21. }
  22. },
  23. /**
  24. * 组件的初始数据
  25. */
  26. data: {
  27. imgUrl:app.globalData.imgUrl,
  28. homearr:[
  29. {id:1,name:'1室'},
  30. {id:2,name:'2室'},
  31. {id:3,name:'3室'},
  32. {id:4,name:'4室'},
  33. {id:5,name:'5室'},
  34. {id:6,name:'6室'},
  35. {id:7,name:'7室'},
  36. {id:8,name:'8室'},
  37. {id:9,name:'9室'},
  38. {id:10,name:'10室'}],
  39. hidx:2,
  40. liveroom:[
  41. {id:1,name:'1厅'},
  42. {id:2,name:'2厅'},
  43. {id:3,name:'3厅'},
  44. {id:4,name:'4厅'},
  45. {id:5,name:'5厅'}
  46. ],
  47. lidx:1,
  48. tolitarr:[
  49. {id:1,name:'1卫'},
  50. {id:2,name:'2卫'},
  51. {id:3,name:'3卫'},
  52. {id:4,name:'4卫'},
  53. {id:5,name:'5卫'}
  54. ],
  55. tidx:0,
  56. area:'',
  57. community:''
  58. },
  59. ready() {
  60. console.log(this.data.rType,this.data.curId,'<<<<')
  61. },
  62. methods:{
  63. dothis(){},
  64. setareatap(e){
  65. this.setData({
  66. area:e.detail.value
  67. })
  68. },
  69. bindPickerChange: function(e) {
  70. this.setData({
  71. hidx: e.detail.value
  72. })
  73. },
  74. bindliveChange: function(e) {
  75. this.setData({
  76. lidx: e.detail.value
  77. })
  78. },
  79. bindtolietChange: function(e) {
  80. this.setData({
  81. tidx: e.detail.value
  82. })
  83. },
  84. isPhoneNum: function (phone) {
  85. var myreg = /^(((13[0-9]{1})|(14[0-9]{1})|(15[0-9]{1})|(16[0-9]{1})|(17[0-9]{1})|(18[0-9]{1})|(19[0-9]{1}))+\d{8})$/;
  86. if (!myreg.test(phone)) {
  87. return false;
  88. }
  89. return true;
  90. },
  91. setcommunitytap(e){
  92. this.setData({
  93. community: e.detail.value
  94. })
  95. },
  96. closetap(){
  97. this.triggerEvent("run", {type: 'close'})
  98. },
  99. /**
  100. * 获取手机号
  101. */
  102. getPhoneNumberTap: function (res) {
  103. var that = this;
  104. if (res.detail.errMsg == 'getPhoneNumber:ok') {
  105. utils.$post({
  106. url: app.globalData.webUrl + 'api/users/setUserMobile',
  107. data: {
  108. encryptedData: res.detail.encryptedData,
  109. iv: res.detail.iv
  110. },
  111. header: {
  112. 'Authorization': 'bearer ' + app.globalData.token
  113. },
  114. success: function (r) {
  115. if (r.data.code == '0') {
  116. that.subfun(r.data.mobile)
  117. } else {
  118. that.setData({
  119. errorText: r.data.msg,
  120. errorflag: true
  121. })
  122. }
  123. }
  124. })
  125. }
  126. },
  127. subfun(phone){
  128. const that=this;
  129. if(!that.data.area){
  130. wx.showToast({
  131. title: "房屋面积不能为空",
  132. icon: 'none',
  133. duration: 2000
  134. })
  135. return false;
  136. }
  137. if(!that.data.community){
  138. wx.showToast({
  139. title: "小区名称不能为空",
  140. icon: 'none',
  141. duration: 2000
  142. })
  143. return false;
  144. }
  145. wx.showLoading({
  146. title: '计算中...',
  147. })
  148. var bedRoom = `${that.data.homearr[that.data.hidx].name}${that.data.liveroom[that.data.lidx].name}${that.data.tolitarr[that.data.tidx].name}`;
  149. utils.$post({
  150. url: app.globalData.webUrl + 'client/index/getDecorationDesign',
  151. header: {
  152. 'Authorization':'bearer '+app.globalData.token
  153. },
  154. data:{
  155. type: that.data.rType,
  156. id: that.data.curId,
  157. community: that.data.community,
  158. area:that.data.area,
  159. bedroom: bedRoom,//*室*厅*卫
  160. mobile: phone,
  161. },
  162. success: function (res) {
  163. // wx.hideLoading();
  164. if(res.data.code=='0'){
  165. that.triggerEvent("run", {type: 'success'})
  166. wx.showToast({
  167. title: res.data.msg,
  168. icon: 'none',
  169. duration: 2000
  170. })
  171. }
  172. }
  173. })
  174. },
  175. }
  176. })