createin.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  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, report_open: 1, 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, report_open: 1, 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. phone_type: 1,
  199. name: that.form.name,
  200. phone: that.form.phone,
  201. sex: that.form.sex,
  202. remark: that.form.remark,
  203. estate_id: that.form.estate_id,
  204. estate_name: that.form.estate_name,
  205. }).then(res => {
  206. uni.$msgConfirm('报备成功,是否前往报备列表?', () => {
  207. uni.navigateTo({
  208. url: '/pages/agent/recommend/list'
  209. })
  210. }, () => {
  211. this.form = {
  212. name: null,
  213. phone: null,
  214. sex: 'male',
  215. remark: null,
  216. estate_id: null,
  217. estate_name: null,
  218. }
  219. })
  220. })
  221. } else {
  222. console.log('验证失败');
  223. }
  224. });
  225. },
  226. // 获取手机号
  227. getPhoneNumber: function(e) {
  228. // 点击获取手机号码按钮
  229. let _that = this;
  230. if (e.detail.errMsg == 'getPhoneNumber:fail user deny') {
  231. _that.$refs.uToast.show({
  232. title: '您可以在个人设置中再次绑定',
  233. type: 'warning'
  234. });
  235. setTimeout(() => {
  236. _that.reLunchUser();
  237. }, 1500);
  238. return; // 即用户拒绝授权
  239. }
  240. console.log(e.detail.errMsg);
  241. console.log(e.detail.iv);
  242. console.log(e.detail.encryptedData);
  243. let iv = e.detail.iv;
  244. let encryptedData = e.detail.encryptedData;
  245. // 不是登陆完第一时间授权
  246. wx.login({
  247. success(res) {
  248. if (res.code) {
  249. // 设置用户手机号
  250. _that.setUserPhoneNumber(encryptedData, iv, res.code);
  251. } else {
  252. this.$refs.uToast.show({
  253. title: res.errMsg,
  254. type: 'warning'
  255. });
  256. console.log('登录失败!' + res.errMsg);
  257. }
  258. }
  259. });
  260. },
  261. // 以下是工具函数
  262. // 关闭键盘
  263. hideKeyboard() {
  264. uni.hideKeyboard();
  265. },
  266. // 格式化日期的月份或天数的显示(小于10,在前面增加0)
  267. getFormatDate(value) {
  268. if (value == undefined || value == '') {
  269. return '';
  270. }
  271. var str = value;
  272. if (parseInt(value) < 10) {
  273. str = '0' + value;
  274. }
  275. return str;
  276. }
  277. }
  278. };
  279. </script>
  280. <style lang="scss">
  281. .page {
  282. padding: 20rpx;
  283. background-color: #ffffff;
  284. }
  285. .form {
  286. border-radius: 10rpx;
  287. padding: 0 40rpx;
  288. }
  289. .popup-body {
  290. .tips-title {
  291. font-size: $u-p;
  292. margin-bottom: 20rpx;
  293. }
  294. .tips-content {
  295. font-size: $u-p2;
  296. color: $u-tips-color;
  297. margin-bottom: 60rpx;
  298. }
  299. }
  300. .id_card {
  301. color: #606266;
  302. width: 100%;
  303. height: 350rpx;
  304. display: flex;
  305. flex-direction: column;
  306. align-items: center;
  307. justify-content: center;
  308. background-color: #f4f5f6;
  309. font-size: $u-p2;
  310. }
  311. .footer {
  312. position: absolute;
  313. text-align: center;
  314. bottom: 40rpx;
  315. font-size: $u-p2;
  316. .agreement {
  317. color: $u-type-error;
  318. }
  319. }
  320. .slot-content {
  321. font-size: 28rpx;
  322. color: $u-content-color;
  323. padding: 20rpx;
  324. }
  325. .scoped-estate-list {
  326. .sel-item {
  327. display: flex;
  328. border-bottom: 1PX solid #dcdcdc;
  329. padding: 20rpx;
  330. &.cur {
  331. background: #369af7;
  332. border-radius: 10rpx;
  333. overflow: hidden;
  334. .img {
  335. opacity: .6;
  336. }
  337. .p1 {
  338. color: #fff;
  339. }
  340. .p3 {
  341. color: #fff;
  342. }
  343. }
  344. }
  345. .sel-left {
  346. width: 180rpx;
  347. border-radius: 10rpx;
  348. .img {
  349. width: 180rpx;
  350. height: 120rpx;
  351. border-radius: 10rpx;
  352. }
  353. }
  354. .sel-right {
  355. // width: 450rpx;
  356. margin-left: 20rpx;
  357. .p1 {
  358. font-size: 30rpx;
  359. font-weight: bold;
  360. margin-bottom: 10rpx;
  361. }
  362. .p2 {
  363. margin-bottom: 10rpx;
  364. }
  365. .p3 {
  366. color: #369af7;
  367. font-size: 24rpx;
  368. font-weight: bold;
  369. }
  370. }
  371. }
  372. .scoped-estate-popup {
  373. height: 100%;
  374. padding-bottom: 100rpx;
  375. .popup-body {
  376. box-sizing: border-box;
  377. border-bottom: 1PX solid #dcdcdc;
  378. }
  379. }
  380. .scoped-popup-header-input {
  381. position: fixed;
  382. width: 90%;
  383. display: flex;
  384. border-bottom: 1PX solid #dcdcdc;
  385. .input {
  386. flex: 1;
  387. padding-left: 20rpx;
  388. height: 80rpx;
  389. .u-input__input {
  390. height: 80rpx;
  391. }
  392. }
  393. .b {
  394. width: 200rpx;
  395. height: 80rpx;
  396. line-height: 80rpx;
  397. background: #2d8cf0;
  398. color: #fff;
  399. text-align: center;
  400. margin-left: 20rpx;
  401. }
  402. }
  403. </style>