join.vue 11 KB

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