join.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  1. <template>
  2. <view class="page">
  3. <view class="form">
  4. <u-form :model="form" ref="uForm">
  5. <u-form-item label-width="150" label="姓名" prop="name" required>
  6. <u-input placeholder="请输入客户姓名" v-model="form.name" type="text"></u-input>
  7. </u-form-item>
  8. <u-form-item label-width="150" label="性别" prop="sex" required>
  9. <u-radio-group v-model="form.sex" active-color="#2979ff">
  10. <u-radio name="male">先生</u-radio>
  11. <u-radio name="female">女士</u-radio>
  12. </u-radio-group>
  13. </u-form-item>
  14. <u-form-item label-width="150" label="意向项目" prop="estate_name" required>
  15. <u-input type="select" :select-open="propertySelectShow" v-model="form.estate_name" placeholder="请选择推荐项目" @click="propertySelectShow = true"></u-input>
  16. <!-- <u-input type="select" :select-open="propertySelectShow" v-model="form.estate_name" placeholder="请选择推荐项目" @click="openEstateList"></u-input> -->
  17. </u-form-item>
  18. <u-form-item v-if="form.phone_type == '2'" label-width="150" label="手机号">
  19. <view @click.native="phoneHandle" style="position: absolute;left: 0;top: 0;width: 40px;height: 40px;"></view>
  20. <u-input placeholder="输前三" v-model="phoneBefore3" type="number" style="display: inline-block;width: 70px;" input-align="right"></u-input>
  21. <view style="display: inline-block;">****</view>
  22. <u-input placeholder="输后四" v-model="phoneAfter4" type="number" style="display: inline-block;width: 70px;"></u-input>
  23. </u-form-item>
  24. <u-form-item v-else label-width="150" label="手机号" prop="phone" required>
  25. <view @click.native="phoneHandle" style="position: absolute;left: 0;top: 0;width: 40px;height: 40px;"></view>
  26. <u-input placeholder="请输入手机号" v-model="form.phone" type="number"></u-input>
  27. </u-form-item>
  28. <u-form-item label-width="150" label="备注信息" prop="remark" label-position="top">
  29. <u-input placeholder="客户描述说明,如客户意向户型或面积等信息" v-model="form.remark" type="textarea"></u-input>
  30. </u-form-item>
  31. </u-form>
  32. <u-gap height="60"></u-gap>
  33. <u-button type="primary" :diabled="submitButtonDisabled" @click="submitHandle">提交</u-button>
  34. </view>
  35. <!-- 列表选择 -->
  36. <!-- <u-select mode="single-column" :list="propertySelectList" v-model="propertySelectShow" @confirm="propertySelectConfirm"></u-select> -->
  37. <u-select mode="single-column" :list="salerSelectList" v-model="salerSelectShow" @confirm="salerSelectConfirm"></u-select>
  38. <!-- modal -->
  39. <u-modal v-model="submitModalShow" content="请务必仔细确认各项信息是否正确" :show-cancel-button="true" @confirm="submit()"></u-modal>
  40. <u-modal v-model="modalShow" :content="modalContent" :show-cancel-button="true" @cancel="modalCancel()" @confirm="modalConfirm()"></u-modal>
  41. <!-- utoast -->
  42. <u-toast ref="uToast" />
  43. <u-popup v-model="propertySelectShow" mode="center" width="90%" height="100%">
  44. <view class="bwin-popup scoped-estate-popup">
  45. <view class="scoped-popup-header-input">
  46. <u-input class="input" v-model="curEstateName" placeholder="没找到楼盘??点这输入关键字搜索"></u-input>
  47. <view class="b" @click="getEstateList">搜索</view>
  48. </view>
  49. <scroll-view :scroll-y="true" class="popup-body">
  50. <view class="scoped-estate-list">
  51. <view v-for="(item, index) in estateList" :class="eIds.indexOf(item.id) > -1 ? 'sel-item cur' : 'sel-item'" @click="listItemHandle(item)" :key="index">
  52. <view class="sel-left">
  53. <image class="img" :src="item.pri_image" mode="aspectFill"></image>
  54. </view>
  55. <view class="sel-right">
  56. <view class="p1">{{item.estate_name}}</view>
  57. <view class="p2">
  58. <u-tag
  59. :text="areaTypeObj[item.area_type]"
  60. :type="'success'"
  61. size="mini"
  62. ></u-tag>
  63. </view>
  64. <view class="p3" v-if="userInfo2.auth_state == 1">带看需收集:{{ item.report_visit }}</view>
  65. <view class="p3" v-if="userInfo2.auth_state == 1">报备/带看保护期:{{ item.report_lock }}天/{{ item.lead_lock }}天</view>
  66. </view>
  67. </view>
  68. </view>
  69. </scroll-view>
  70. <view class="popup-footer" style="position: fixed;bottom: 12rpx;">
  71. <u-button size="medium" @click="clearListHandle">清空</u-button>
  72. <u-button size="medium" type="primary" @click="saveListHandle">确定</u-button>
  73. </view>
  74. </view>
  75. </u-popup>
  76. </view>
  77. </template>
  78. <script>
  79. import { arrToObj } from '@/utils'
  80. export default {
  81. data() {
  82. return {
  83. form: {
  84. name: null,
  85. phone: null,
  86. sex: 'male',
  87. remark: null,
  88. phone_type: '1',
  89. saler_id: null,
  90. saler_name: null
  91. },
  92. eIds: [],
  93. eArr: [],
  94. phoneBefore3: '',
  95. phoneAfter4: '',
  96. customer_id: null,
  97. submitButtonDisabled: true,
  98. rules: {
  99. name: [
  100. {
  101. required: true,
  102. message: '姓名不得为空',
  103. trigger: ['change', 'blur']
  104. },
  105. ],
  106. phone: [
  107. {
  108. required: true,
  109. message: '手机号不得为空',
  110. trigger: ['change', 'blur']
  111. },
  112. // 11个字符判断
  113. {
  114. len: 11,
  115. message: '手机号格式不正确',
  116. trigger: ['change', 'blur']
  117. },
  118. ],
  119. estate_name: [
  120. {
  121. required: true,
  122. message: '意向项目不能为空',
  123. trigger: ['change']
  124. },
  125. ]
  126. },
  127. propertySelectShow: false,
  128. propertySelectList: [],
  129. estateList: [],
  130. areaTypeObj: {},
  131. userInfo2: {},
  132. curEstateName: '',
  133. salerSelectShow: false,
  134. salerSelectList: [],
  135. submitModalShow: false,
  136. modalShow: false,
  137. modalContent: ''
  138. };
  139. },
  140. onLoad(data) {
  141. const that = this
  142. const eventChannel = that.getOpenerEventChannel(); // that 需指向 this
  143. // 监听data事件,获取上一页面通过eventChannel.emit传送到当前页面的数据
  144. if (eventChannel.on) {
  145. eventChannel.on('data', data => {
  146. if(data.info.name) that.form.name = data.info.name;
  147. if(data.info.phone) that.form.phone = data.info.phone;
  148. if(data.info.sex) that.form.sex = data.info.sex;
  149. if(data.info.demand) that.form.remark = data.info.demand;
  150. })
  151. }
  152. },
  153. created () {
  154. this.userInfo2 = uni.getStorageSync('MD_userInfo2')
  155. const dictObj = uni.getStorageSync('MD_dict')
  156. this.areaTypeObj = arrToObj(dictObj.area_type)
  157. uni.api.estate.apiestatelist({page_size: 100, report_open: 1, is_pub: 1}).then(res => {
  158. let list = res.list || []
  159. this.estateList = [...list]
  160. })
  161. },
  162. // 必须要在onReady生命周期,因为onLoad生命周期组件可能尚未创建完毕
  163. onReady() {
  164. this.$refs.uForm.setRules(this.rules);
  165. },
  166. methods: {
  167. phoneHandle () {
  168. let p = this.form.phone
  169. p = p.replace(/ /g, '')
  170. this.form.phone = p
  171. this.form = {...this.form}
  172. },
  173. getEstateList () {
  174. uni.api.estate.apiestatelist({page_size: 100, report_open: 1, is_pub: 1, estate_name: this.curEstateName}).then(res => {
  175. let list = res.list || []
  176. this.estateList = [...list]
  177. })
  178. },
  179. listItemHandle (val) {
  180. let eIds = [...this.eIds]
  181. let eArr = [...this.eArr]
  182. let cIndex = eIds.indexOf(val.estate_id)
  183. if (cIndex > -1 ) {
  184. eIds.splice(cIndex,1)
  185. eArr.splice(cIndex,1)
  186. } else {
  187. eIds.push(val.estate_id)
  188. eArr.push(val)
  189. }
  190. this.eIds = [...eIds]
  191. this.eArr = [...eArr]
  192. },
  193. clearListHandle () {
  194. this.propertySelectShow = false
  195. this.eIds = []
  196. this.eArr = []
  197. this.form.estate_name = ''
  198. },
  199. saveListHandle () {
  200. let errMsg = ''
  201. let eNames = this.eArr.map(item => {
  202. if (item.phone_type == '2') {
  203. errMsg = item.estate_name
  204. }
  205. return item.estate_name
  206. })
  207. this.form.estate_name = eNames.join(',')
  208. if (this.eArr.length === 1 && this.eArr[0].phone_type == '2') {
  209. this.form.phone_type = '2'
  210. } else {
  211. this.form.phone_type = '1'
  212. }
  213. if (errMsg && this.eArr.length > 1) {
  214. uni.$msg(`${errMsg}是前三后四报备项目,请单独报备`)
  215. } else {
  216. this.propertySelectShow = false
  217. }
  218. },
  219. // // 选择所属项目回调
  220. // propertySelectConfirm(e) {
  221. // e.map((val, index) => {
  222. // this.form.estate_id = val.value;
  223. // this.form.estate_name = val.label;
  224. // });
  225. // },
  226. // openEstateList () {
  227. // uni.navigateTo({
  228. // url: `/pages/estate/list?eid=${this.form.estate_id}&ename=${this.form.estate_name}`
  229. // })
  230. // },
  231. submitHandle() {
  232. const that = this
  233. this.$refs.uForm.validate(valid => {
  234. if (valid) {
  235. // 验证成功
  236. let params = {
  237. phone_type: that.form.phone_type || '1',
  238. name: that.form.name,
  239. phone: that.form.phone.replace(/\s+/g, ''),
  240. sex: that.form.sex,
  241. remark: that.form.remark,
  242. // estate_id: that.form.estate_id,
  243. // estate_name: that.form.estate_name,
  244. }
  245. if (params.phone_type == '2') {
  246. if (that.phoneBefore3 && that.phoneAfter4) {
  247. params.phone = `${that.phoneBefore3}****${that.phoneAfter4}`
  248. } else {
  249. that.$refs.uToast.show({
  250. title: '请输入报备手机号的前三后四',
  251. type: 'warning'
  252. });
  253. return
  254. }
  255. }
  256. this.eArr.forEach((eObj, i) => {
  257. let newParams = {...params}
  258. newParams.estate_id = eObj.estate_id
  259. newParams.estate_name = eObj.estate_name
  260. uni.api.estate.apireportadd(newParams).then(res => {
  261. if (i === this.eArr.length - 1) {
  262. uni.$msgConfirm('报备成功,是否前往报备列表?', () => {
  263. uni.navigateTo({
  264. url: '/pages/agent/recommend/list'
  265. })
  266. }, () => {
  267. this.form = {
  268. name: null,
  269. phone: null,
  270. sex: 'male',
  271. remark: null,
  272. }
  273. })
  274. }
  275. })
  276. })
  277. } else {
  278. console.log('验证失败');
  279. }
  280. });
  281. },
  282. // 获取手机号
  283. getPhoneNumber: function(e) {
  284. // 点击获取手机号码按钮
  285. let _that = this;
  286. if (e.detail.errMsg == 'getPhoneNumber:fail user deny') {
  287. _that.$refs.uToast.show({
  288. title: '您可以在个人设置中再次绑定',
  289. type: 'warning'
  290. });
  291. setTimeout(() => {
  292. _that.reLunchUser();
  293. }, 1500);
  294. return; // 即用户拒绝授权
  295. }
  296. console.log(e.detail.errMsg);
  297. console.log(e.detail.iv);
  298. console.log(e.detail.encryptedData);
  299. let iv = e.detail.iv;
  300. let encryptedData = e.detail.encryptedData;
  301. // 不是登陆完第一时间授权
  302. wx.login({
  303. success(res) {
  304. if (res.code) {
  305. // 设置用户手机号
  306. _that.setUserPhoneNumber(encryptedData, iv, res.code);
  307. } else {
  308. this.$refs.uToast.show({
  309. title: res.errMsg,
  310. type: 'warning'
  311. });
  312. console.log('登录失败!' + res.errMsg);
  313. }
  314. }
  315. });
  316. },
  317. // 以下是工具函数
  318. // 关闭键盘
  319. hideKeyboard() {
  320. uni.hideKeyboard();
  321. },
  322. // 格式化日期的月份或天数的显示(小于10,在前面增加0)
  323. getFormatDate(value) {
  324. if (value == undefined || value == '') {
  325. return '';
  326. }
  327. var str = value;
  328. if (parseInt(value) < 10) {
  329. str = '0' + value;
  330. }
  331. return str;
  332. }
  333. }
  334. };
  335. </script>
  336. <style lang="scss">
  337. .page {
  338. padding: 20rpx;
  339. background-color: #ffffff;
  340. }
  341. .form {
  342. border-radius: 10rpx;
  343. padding: 0 40rpx;
  344. }
  345. .popup-body {
  346. .tips-title {
  347. font-size: $u-p;
  348. margin-bottom: 20rpx;
  349. }
  350. .tips-content {
  351. font-size: $u-p2;
  352. color: $u-tips-color;
  353. margin-bottom: 60rpx;
  354. }
  355. }
  356. .id_card {
  357. color: #606266;
  358. width: 100%;
  359. height: 350rpx;
  360. display: flex;
  361. flex-direction: column;
  362. align-items: center;
  363. justify-content: center;
  364. background-color: #f4f5f6;
  365. font-size: $u-p2;
  366. }
  367. .footer {
  368. position: absolute;
  369. text-align: center;
  370. bottom: 40rpx;
  371. font-size: $u-p2;
  372. .agreement {
  373. color: $u-type-error;
  374. }
  375. }
  376. .slot-content {
  377. font-size: 28rpx;
  378. color: $u-content-color;
  379. padding: 20rpx;
  380. }
  381. .scoped-estate-list {
  382. .sel-item {
  383. display: flex;
  384. border-bottom: 1PX solid #dcdcdc;
  385. padding: 20rpx;
  386. &.cur {
  387. background: #369af7;
  388. border-radius: 10rpx;
  389. overflow: hidden;
  390. .img {
  391. opacity: .6;
  392. }
  393. .p1 {
  394. color: #fff;
  395. }
  396. .p3 {
  397. color: #fff;
  398. }
  399. }
  400. }
  401. .sel-left {
  402. width: 180rpx;
  403. border-radius: 10rpx;
  404. .img {
  405. width: 180rpx;
  406. height: 120rpx;
  407. border-radius: 10rpx;
  408. }
  409. }
  410. .sel-right {
  411. // width: 450rpx;
  412. margin-left: 20rpx;
  413. .p1 {
  414. font-size: 30rpx;
  415. font-weight: bold;
  416. margin-bottom: 10rpx;
  417. }
  418. .p2 {
  419. margin-bottom: 10rpx;
  420. }
  421. .p3 {
  422. color: #369af7;
  423. font-size: 24rpx;
  424. font-weight: bold;
  425. }
  426. }
  427. }
  428. .scoped-estate-popup {
  429. height: 100%;
  430. padding-bottom: 100rpx;
  431. .popup-body {
  432. box-sizing: border-box;
  433. border-bottom: 1PX solid #dcdcdc;
  434. }
  435. }
  436. .scoped-popup-header-input {
  437. position: fixed;
  438. width: 90%;
  439. display: flex;
  440. border-bottom: 1PX solid #dcdcdc;
  441. .input {
  442. flex: 1;
  443. padding-left: 20rpx;
  444. height: 80rpx;
  445. .u-input__input {
  446. height: 80rpx;
  447. }
  448. }
  449. .b {
  450. width: 200rpx;
  451. height: 80rpx;
  452. line-height: 80rpx;
  453. background: #2d8cf0;
  454. color: #fff;
  455. text-align: center;
  456. margin-left: 20rpx;
  457. }
  458. }
  459. </style>