join2.vue 9.0 KB

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