join2.vue 10 KB

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