join.vue 11 KB

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