join2.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450
  1. <template>
  2. <view class="page">
  3. <view class="scoped-header">
  4. <view class="p1" style="color: #f00;font-weight: bold;">{{ curObj.estate_name || '' }} {{ curObj.remark || '' }}</view>
  5. <view class="p2" style="color: #f00;font-weight: bold;">截至时间:{{ curObj.end_at || ''}}</view>
  6. </view>
  7. <view class="form">
  8. <u-form :model="form" ref="uForm">
  9. <u-form-item label-width="150" label="公司/门店" prop="info1" required>
  10. <u-input placeholder="请输入公司/门店" v-model="form.info1" type="text"></u-input>
  11. </u-form-item>
  12. <u-form-item label-width="150" label="名字" prop="info2" required>
  13. <u-input placeholder="请输入名字" v-model="form.info2" type="text"></u-input>
  14. </u-form-item>
  15. <u-form-item label-width="150" label="电话" prop="info3" required>
  16. <u-input placeholder="请输入电话" v-model="form.info3" type="number"></u-input>
  17. </u-form-item>
  18. <u-form-item label-width="150" label="参加人数" prop="info4" required>
  19. <u-input placeholder="请输入参加人数" v-model="form.info4" type="number"></u-input>
  20. </u-form-item>
  21. <u-form-item label-width="150" label="办公区域" prop="info5" required>
  22. <u-input placeholder="请输入办公区域" v-model="form.info5" disabled @click="areaOpen" type="text"></u-input>
  23. </u-form-item>
  24. </u-form>
  25. <u-gap height="60"></u-gap>
  26. <u-button type="primary" @click="submitHandle">提交</u-button>
  27. </view>
  28. <u-select v-model="isareaShow" :list="areaList" label-name="dict_label" @confirm="areaClose"></u-select>
  29. </view>
  30. </template>
  31. <script>
  32. import { arrToObj } from '@/utils'
  33. export default {
  34. data() {
  35. return {
  36. curId: '',
  37. curObj: {},
  38. isareaShow: false,
  39. areaList: [],
  40. form: {
  41. info1: null,
  42. info2: null,
  43. info3: null,
  44. info4: null,
  45. info5: null,
  46. },
  47. eIds: [],
  48. eArr: [],
  49. phoneBefore3: '',
  50. phoneAfter4: '',
  51. customer_id: null,
  52. submitButtonDisabled: true,
  53. rules: {
  54. info1: [
  55. {
  56. required: true,
  57. message: '公司/门店不得为空',
  58. trigger: ['change', 'blur']
  59. },
  60. ],
  61. info2: [
  62. {
  63. required: true,
  64. message: '名字不得为空',
  65. trigger: ['change', 'blur']
  66. },
  67. ],
  68. info3: [
  69. {
  70. required: true,
  71. message: '电话不得为空',
  72. trigger: ['change', 'blur']
  73. },
  74. ],
  75. info4: [
  76. {
  77. required: true,
  78. message: '参加人数不得为空',
  79. trigger: ['change', 'blur']
  80. },
  81. ],
  82. info5: [
  83. {
  84. required: true,
  85. message: '办公区域不得为空',
  86. trigger: ['change', 'blur']
  87. },
  88. ],
  89. },
  90. propertySelectShow: false,
  91. propertySelectList: [],
  92. estateList: [],
  93. areaTypeObj: {},
  94. userInfo2: {},
  95. curEstateName: '',
  96. salerSelectShow: false,
  97. salerSelectList: [],
  98. submitModalShow: false,
  99. modalShow: false,
  100. modalContent: ''
  101. };
  102. },
  103. onLoad(data) {
  104. const curId = data.id
  105. this.curId = curId || ''
  106. uni.api.cust.apiactivityinfo({id: this.curId}).then(res => {
  107. this.curObj = res.activity || {}
  108. })
  109. const dictObj = uni.getStorageSync('MD_dict') || {}
  110. const atArr = dictObj.area_type || []
  111. let areaList = []
  112. atArr.forEach(item => {
  113. if (item.dict_label !== '独家合作' && item.dict_label !== '安义县' && item.dict_label !== '宜春' ) {
  114. areaList.push(item)
  115. }
  116. })
  117. this.areaList = [...areaList]
  118. },
  119. onShareAppMessage(options) {
  120. var shareObj = {
  121. title: `${this.curObj.estate_name}${this.curObj.remark}`,
  122. path: `/pages/agent/activity/join?id=${this.curId}`,
  123. success: function(res) {
  124. },
  125. complete: function(res) {
  126. console.log(res)
  127. },
  128. }
  129. return shareObj
  130. },
  131. onShareTimeline(options) {
  132. var shareObj = {
  133. title: `${this.curObj.estate_name}${this.curObj.remark}`,
  134. path: `/pages/agent/activity/join?id=${this.curId}`,
  135. success: function(res) {
  136. },
  137. complete: function(res) {
  138. console.log(res)
  139. },
  140. }
  141. return shareObj
  142. },
  143. created () {
  144. },
  145. // 必须要在onReady生命周期,因为onLoad生命周期组件可能尚未创建完毕
  146. onReady() {
  147. this.$refs.uForm.setRules(this.rules);
  148. },
  149. methods: {
  150. areaOpen () {
  151. this.isareaShow = true
  152. },
  153. areaClose (arr) {
  154. this.isareaShow = false
  155. if (arr) {
  156. this.form.info5 = arr[0].label
  157. }
  158. },
  159. phoneHandle () {
  160. let p = this.form.phone
  161. p = p.replace(/ /g, '')
  162. this.form.phone = p
  163. this.form = {...this.form}
  164. },
  165. getEstateList () {
  166. uni.api.estate.apiestatelist({page_size: 100, report_open: 1, is_inner: 2, estate_name: this.curEstateName}).then(res => {
  167. let list = res.list || []
  168. this.estateList = [...list]
  169. })
  170. },
  171. listItemHandle (val) {
  172. let eIds = [...this.eIds]
  173. let eArr = [...this.eArr]
  174. let cIndex = eIds.indexOf(val.estate_id)
  175. if (cIndex > -1 ) {
  176. eIds.splice(cIndex,1)
  177. eArr.splice(cIndex,1)
  178. } else {
  179. eIds.push(val.estate_id)
  180. eArr.push(val)
  181. }
  182. this.eIds = [...eIds]
  183. this.eArr = [...eArr]
  184. },
  185. clearListHandle () {
  186. this.propertySelectShow = false
  187. this.eIds = []
  188. this.eArr = []
  189. this.form.estate_name = ''
  190. },
  191. saveListHandle () {
  192. let errMsg = ''
  193. let eNames = this.eArr.map(item => {
  194. if (item.phone_type == '2') {
  195. errMsg = item.estate_name
  196. }
  197. return item.estate_name
  198. })
  199. this.form.estate_name = eNames.join(',')
  200. if (this.eArr.length === 1 && this.eArr[0].phone_type == '2') {
  201. this.form.phone_type = '2'
  202. } else {
  203. this.form.phone_type = '1'
  204. }
  205. if (errMsg && this.eArr.length > 1) {
  206. uni.$msg(`${errMsg}是前三后四报备项目,请单独报备`)
  207. } else {
  208. this.propertySelectShow = false
  209. }
  210. },
  211. // // 选择所属项目回调
  212. // propertySelectConfirm(e) {
  213. // e.map((val, index) => {
  214. // this.form.estate_id = val.value;
  215. // this.form.estate_name = val.label;
  216. // });
  217. // },
  218. // openEstateList () {
  219. // uni.navigateTo({
  220. // url: `/pages/estate/list?eid=${this.form.estate_id}&ename=${this.form.estate_name}`
  221. // })
  222. // },
  223. submitHandle() {
  224. const that = this
  225. this.$refs.uForm.validate(valid => {
  226. if (valid) {
  227. // 验证成功
  228. let params = {
  229. activity_id: that.curId,
  230. info1: that.form.info1,
  231. info2: that.form.info2,
  232. info3: that.form.info3,
  233. info4: that.form.info4,
  234. info5: that.form.info5,
  235. }
  236. uni.api.cust.apiactivityenroll(params).then(res => {
  237. uni.$msgConfirm('报名成功', () => {
  238. uni.redirectTo({
  239. url: `/pages/index/index`
  240. })
  241. }, () => {
  242. uni.redirectTo({
  243. url: `/pages/index/index`
  244. })
  245. })
  246. })
  247. } else {
  248. console.log('验证失败');
  249. }
  250. });
  251. },
  252. // 获取手机号
  253. getPhoneNumber: function(e) {
  254. // 点击获取手机号码按钮
  255. let _that = this;
  256. if (e.detail.errMsg == 'getPhoneNumber:fail user deny') {
  257. _that.$refs.uToast.show({
  258. title: '您可以在个人设置中再次绑定',
  259. type: 'warning'
  260. });
  261. setTimeout(() => {
  262. _that.reLunchUser();
  263. }, 1500);
  264. return; // 即用户拒绝授权
  265. }
  266. console.log(e.detail.errMsg);
  267. console.log(e.detail.iv);
  268. console.log(e.detail.encryptedData);
  269. let iv = e.detail.iv;
  270. let encryptedData = e.detail.encryptedData;
  271. // 不是登陆完第一时间授权
  272. wx.login({
  273. success(res) {
  274. if (res.code) {
  275. // 设置用户手机号
  276. _that.setUserPhoneNumber(encryptedData, iv, res.code);
  277. } else {
  278. this.$refs.uToast.show({
  279. title: res.errMsg,
  280. type: 'warning'
  281. });
  282. console.log('登录失败!' + res.errMsg);
  283. }
  284. }
  285. });
  286. },
  287. // 以下是工具函数
  288. // 关闭键盘
  289. hideKeyboard() {
  290. uni.hideKeyboard();
  291. },
  292. // 格式化日期的月份或天数的显示(小于10,在前面增加0)
  293. getFormatDate(value) {
  294. if (value == undefined || value == '') {
  295. return '';
  296. }
  297. var str = value;
  298. if (parseInt(value) < 10) {
  299. str = '0' + value;
  300. }
  301. return str;
  302. }
  303. }
  304. };
  305. </script>
  306. <style lang="scss">
  307. .page {
  308. padding: 20rpx;
  309. background-color: #ffffff;
  310. }
  311. .form {
  312. border-radius: 10rpx;
  313. padding: 0 40rpx;
  314. }
  315. .popup-body {
  316. .tips-title {
  317. font-size: $u-p;
  318. margin-bottom: 20rpx;
  319. }
  320. .tips-content {
  321. font-size: $u-p2;
  322. color: $u-tips-color;
  323. margin-bottom: 60rpx;
  324. }
  325. }
  326. .id_card {
  327. color: #606266;
  328. width: 100%;
  329. height: 350rpx;
  330. display: flex;
  331. flex-direction: column;
  332. align-items: center;
  333. justify-content: center;
  334. background-color: #f4f5f6;
  335. font-size: $u-p2;
  336. }
  337. .footer {
  338. position: absolute;
  339. text-align: center;
  340. bottom: 40rpx;
  341. font-size: $u-p2;
  342. .agreement {
  343. color: $u-type-error;
  344. }
  345. }
  346. .slot-content {
  347. font-size: 28rpx;
  348. color: $u-content-color;
  349. padding: 20rpx;
  350. }
  351. .scoped-estate-list {
  352. .sel-item {
  353. display: flex;
  354. border-bottom: 1PX solid #dcdcdc;
  355. padding: 20rpx;
  356. &.cur {
  357. background: #369af7;
  358. border-radius: 10rpx;
  359. overflow: hidden;
  360. .img {
  361. opacity: .6;
  362. }
  363. .p1 {
  364. color: #fff;
  365. }
  366. .p3 {
  367. color: #fff;
  368. }
  369. }
  370. }
  371. .sel-left {
  372. width: 180rpx;
  373. border-radius: 10rpx;
  374. .img {
  375. width: 180rpx;
  376. height: 120rpx;
  377. border-radius: 10rpx;
  378. }
  379. }
  380. .sel-right {
  381. // width: 450rpx;
  382. margin-left: 20rpx;
  383. .p1 {
  384. font-size: 30rpx;
  385. font-weight: bold;
  386. margin-bottom: 10rpx;
  387. }
  388. .p2 {
  389. margin-bottom: 10rpx;
  390. }
  391. .p3 {
  392. color: #369af7;
  393. font-size: 24rpx;
  394. font-weight: bold;
  395. }
  396. }
  397. }
  398. .scoped-estate-popup {
  399. height: 100%;
  400. padding-bottom: 100rpx;
  401. .popup-body {
  402. box-sizing: border-box;
  403. border-bottom: 1PX solid #dcdcdc;
  404. }
  405. }
  406. .scoped-popup-header-input {
  407. position: fixed;
  408. width: 90%;
  409. display: flex;
  410. border-bottom: 1PX solid #dcdcdc;
  411. .input {
  412. flex: 1;
  413. padding-left: 20rpx;
  414. height: 80rpx;
  415. .u-input__input {
  416. height: 80rpx;
  417. }
  418. }
  419. .b {
  420. width: 200rpx;
  421. height: 80rpx;
  422. line-height: 80rpx;
  423. background: #2d8cf0;
  424. color: #fff;
  425. text-align: center;
  426. margin-left: 20rpx;
  427. }
  428. }
  429. </style>