join.vue 11 KB

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