createin.vue 11 KB

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