join.vue 11 KB

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