msBank.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536
  1. <template>
  2. <view>
  3. <view class="info-collect-page">
  4. <!-- 产品信息 -->
  5. <view class="product-info">
  6. <view class="product-left">
  7. <image src="https://7a68-zhaijieshi-3guecm78383ca692-1307626841.tcb.qcloud.la/activity/ms-banner.png" mode="widthFix "></image>
  8. </view>
  9. <view class="product-right">
  10. <view class="title">【民生客户专享】高端保姆1V1匹配服务</view>
  11. <view class="brief">服务类型:住家保姆、白班保姆、育儿嫂、月嫂、钟点工</view>
  12. </view>
  13. </view>
  14. <!-- 信息收集 -->
  15. <view class="collect-detail">
  16. <van-cell-group>
  17. <van-field
  18. v-model="customerName"
  19. label="客户名称"
  20. placeholder-style="color:#85868A;font-size:24rpx;font-family: PingFangSC-Light, helvetica, 'Heiti SC';font-weight:normal"
  21. placeholder="请输入客户名称"
  22. />
  23. <view style="display: flex; justify-content: space-between">
  24. <van-field
  25. disabled
  26. v-model="customerTel"
  27. label="手 机"
  28. placeholder-style="color:#85868A;font-size:24rpx; font-family: PingFangSC-Light, helvetica, 'Heiti SC';font-weight:normal"
  29. placeholder="请输入手机号"
  30. maxlength="11"
  31. />
  32. <van-button type="text" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">授权手机号</van-button>
  33. </view>
  34. <van-field label="住 址" v-model="address" placeholder="请输入详细住址" maxlength="40" />
  35. <van-cell title="服务类型" is-link :value="serviceModelText" @click="showServicePicker" />
  36. <!-- <van-cell title="期望服务时间" is-link value="{{startServiceTime}}" bind:click="showTimePicker" /> -->
  37. </van-cell-group>
  38. </view>
  39. <view class="collect-tip jz-color">*9:30-19:30 3小时内回复;以外时间次日10:30前回复</view>
  40. <!-- 提交按钮 -->
  41. <view class="bottom-fixed-btn-wrapper" style="bottom: 56rpx">
  42. <van-button type="info" v-if="showSubmitBtn" block round @tap.native="confirmSubmit">确认</van-button>
  43. </view>
  44. <van-popup :show="typePickerShow" position="bottom">
  45. <van-picker show-toolbar :columns="typeColumns" @cancel="onTypeCancel" @confirm="onTypeConfirm" />
  46. </van-popup>
  47. <van-popup :show="timePickerShow" position="bottom">
  48. <van-datetime-picker type="date" :value="currentDate" @cancel="onTimeCancel" @confirm="onTimeConfirm" :min-date="minDate" @formatter="formatterDate" />
  49. </van-popup>
  50. </view>
  51. <!-- 展示蒙层 显示赠送会员卡 -->
  52. <view class="poster" v-if="myqr_show">
  53. <view>
  54. <image :show-menu-by-longpress="true" src="https://7a68-zhaijieshi-3guecm78383ca692-1307626841.tcb.qcloud.la/activity/ms-pup.png" mode="widthFix"></image>
  55. <view style="text-align: center; margin-top: 20rpx">
  56. <image class="closeImg" @tap="hidePoster" src="https://7a68-zhaijieshi-3guecm78383ca692-1307626841.tcb.qcloud.la/activity/ms-close.png"></image>
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. </template>
  62. <script>
  63. import Dialog from '@vant/weapp/lib/dialog/dialog';
  64. const util = require('../../../utils/util');
  65. const check = require('../../../utils/check');
  66. const api = require('../../../config/api');
  67. const user = require('../../../utils/user.js');
  68. const app = getApp();
  69. export default {
  70. data() {
  71. return {
  72. code: '',
  73. showSubmitBtn: true,
  74. userInfo: {
  75. nickName: '点击登录',
  76. avatarUrl: '/static/images/new/icon-user.png',
  77. isDis: false
  78. },
  79. hasLogin: false,
  80. myqr_show: false,
  81. infoGoods: app.globalData.infoGoods,
  82. customerName: '',
  83. customerTel: '',
  84. address: '',
  85. addressId: '',
  86. serviceModelText: '请选择',
  87. serviceModel: '',
  88. // startServiceTime:'请选择',
  89. typePickerShow: false,
  90. timePickerShow: false,
  91. serviceModelList: [
  92. {
  93. id: '1',
  94. name: '钟点工'
  95. },
  96. {
  97. id: '2',
  98. name: '白班保姆'
  99. },
  100. {
  101. id: '3',
  102. name: '住家保姆'
  103. },
  104. {
  105. id: '4',
  106. name: '月嫂'
  107. },
  108. {
  109. id: '5',
  110. name: '代班保姆-钟点工'
  111. },
  112. {
  113. id: '6',
  114. name: '代班保姆-保姆'
  115. }
  116. ],
  117. typeColumns: ['钟点工', '白班保姆', '住家保姆', '月嫂', '代班保姆-钟点工', '代班保姆-保姆'],
  118. //typeColumns: ['钟点工', '白班保姆', '住家保姆', '月嫂', '育儿嫂', '其他'],
  119. currentDate: new Date().getTime(),
  120. minDate: new Date().getTime(),
  121. startServiceTime: ''
  122. };
  123. }
  124. /**
  125. * 生命周期函数--监听页面加载
  126. */,
  127. onLoad: function (options) {},
  128. /**
  129. * 生命周期函数--监听页面初次渲染完成
  130. */
  131. onReady: function () {},
  132. /**
  133. * 生命周期函数--监听页面显示
  134. */
  135. onShow: function () {
  136. let that = this;
  137. if (app.globalData.hasLogin) {
  138. let userInfo = uni.getStorageSync('userInfo');
  139. this.setData({
  140. userInfo: userInfo,
  141. hasLogin: true,
  142. customerTel: userInfo.mobile
  143. });
  144. app.globalData.userInfo = userInfo;
  145. } else {
  146. user.login().then((res) => {
  147. console.info(res);
  148. that.setData({
  149. code: res.code
  150. });
  151. });
  152. }
  153. },
  154. /**
  155. * 生命周期函数--监听页面隐藏
  156. */
  157. onHide: function () {},
  158. /**
  159. * 生命周期函数--监听页面卸载
  160. */
  161. onUnload: function () {},
  162. /**
  163. * 页面相关事件处理函数--监听用户下拉动作
  164. */
  165. onPullDownRefresh: function () {},
  166. /**
  167. * 页面上拉触底事件的处理函数
  168. */
  169. onReachBottom: function () {},
  170. /**
  171. * 用户点击右上角分享
  172. */
  173. onShareAppMessage: function () {},
  174. methods: {
  175. showPoster() {
  176. this.setData({
  177. myqr_show: true
  178. });
  179. },
  180. hidePoster() {
  181. this.setData({
  182. myqr_show: false
  183. });
  184. },
  185. selectAddress() {
  186. if (this.hasLogin == false) {
  187. uni.navigateTo({
  188. url: '/pages/auth/login/login'
  189. });
  190. return;
  191. }
  192. uni.navigateTo({
  193. url: '/pages/ucenter/address/address'
  194. });
  195. },
  196. formatterDate(type, value) {
  197. if (type === 'year') {
  198. return `${value}年`;
  199. }
  200. if (type === 'month') {
  201. return `${value}月`;
  202. }
  203. return value;
  204. },
  205. onTimeCancel() {
  206. this.setData({
  207. timePickerShow: false
  208. });
  209. },
  210. onTimeConfirm(event) {
  211. console.log(event);
  212. this.setData({
  213. startServiceTime: util.formetdate(new Date(event.detail)),
  214. timePickerShow: false
  215. });
  216. },
  217. showServicePicker() {
  218. this.setData({
  219. typePickerShow: true
  220. });
  221. },
  222. showTimePicker() {
  223. this.setData({
  224. timePickerShow: true
  225. });
  226. },
  227. onTypeCancel: function () {
  228. this.setData({
  229. typePickerShow: false
  230. });
  231. },
  232. onTypeConfirm: function (event) {
  233. this.setData({
  234. serviceModel: this.serviceModelList[event.detail.index].id,
  235. serviceModelText: event.detail.value,
  236. typePickerShow: false
  237. });
  238. },
  239. confirmSubmit() {
  240. if (this.hasLogin == false) {
  241. uni.navigateTo({
  242. url: '/pages/auth/login/login'
  243. });
  244. return;
  245. }
  246. if (this.customerName == '') {
  247. uni.showToast({
  248. title: '请输入客户名称',
  249. icon: 'none',
  250. duration: 2000
  251. });
  252. return false;
  253. }
  254. if (this.customerTel == '') {
  255. uni.showToast({
  256. title: '请输入手机号',
  257. icon: 'none',
  258. duration: 2000
  259. });
  260. return false;
  261. }
  262. if (this.customerTel == '') {
  263. // util.showErrorToast('请输入正确的手机号码');
  264. uni.showToast({
  265. title: '输入正确的手机号码',
  266. icon: 'none',
  267. duration: 2000
  268. });
  269. return false;
  270. }
  271. if (this.address == '') {
  272. uni.showToast({
  273. title: '请输入详细住址',
  274. icon: 'none',
  275. duration: 2000
  276. });
  277. return false;
  278. }
  279. if (this.serviceModelText == '请选择') {
  280. uni.showToast({
  281. title: '请选择服务类型',
  282. icon: 'none',
  283. duration: 2000
  284. });
  285. return false;
  286. }
  287. let that = this;
  288. console.log('校验成功');
  289. uni.showLoading({
  290. title: '提交中...',
  291. mask: true
  292. });
  293. util.request(
  294. api.addClueMs,
  295. {
  296. customerName: this.customerName,
  297. customerTel: this.customerTel,
  298. address: this.address,
  299. serviceModel: this.serviceModel,
  300. userId: this.userInfo.id
  301. },
  302. 'POST'
  303. )
  304. .then((res) => {
  305. uni.hideLoading();
  306. if (res.errno == 0) {
  307. that.showPoster();
  308. that.setData({
  309. showSubmitBtn: false
  310. });
  311. } else {
  312. util.showErrorToast(res.errmsg);
  313. }
  314. })
  315. .catch(() => {
  316. uni.hideLoading();
  317. });
  318. },
  319. getPhoneNumber: function (e) {
  320. var ivObj = e.detail.iv;
  321. var telObj = e.detail.encryptedData;
  322. var that = this;
  323. //------执行Login---------
  324. util.request(api.AuthRegister, {
  325. code: that.code,
  326. encryptedData: telObj,
  327. iv: ivObj,
  328. r_userid: 0
  329. }).then(function (res) {
  330. if (res.errno === 0) {
  331. //存储用户信息
  332. app.globalData.hasLogin = true;
  333. app.globalData.userInfo = res.data.userInfo;
  334. uni.setStorageSync('userInfo', res.data.userInfo);
  335. uni.setStorageSync('token', res.data.token);
  336. that.setData({
  337. hasLogin: true,
  338. userInfo: res.data.userInfo,
  339. customerTel: res.data.userInfo.mobile
  340. });
  341. uni.showToast({
  342. title: '授权手机号成功',
  343. icon: 'success',
  344. duration: 2000
  345. });
  346. } else {
  347. console.info(res);
  348. uni.showToast({
  349. title: '授权失败请重试',
  350. icon: 'error',
  351. duration: 3000
  352. });
  353. }
  354. });
  355. //-----------------是否授权,授权通过进入主页面,授权拒绝则停留在登陆界面
  356. if (e.detail.errMsg == 'getPhoneNumber:fail user deny') {
  357. //用户点击拒绝
  358. uni.showModal({
  359. title: '警告',
  360. content: '您点击了拒绝授权,部分功能无法使用!!!',
  361. showCancel: false,
  362. confirmText: '确定',
  363. success: function (res) {
  364. // 用户没有授权成功,不需要改变 isHide 的值
  365. if (res.confirm) {
  366. }
  367. }
  368. });
  369. }
  370. }
  371. }
  372. };
  373. </script>
  374. <style>
  375. .info-collect-page {
  376. padding: 0;
  377. }
  378. .product-info {
  379. /* height: 162rpx; */
  380. padding: 12rpx 12rpx 16rpx;
  381. background: #fff;
  382. border-radius: 10rpx;
  383. }
  384. .product-info {
  385. /* display: flex; */
  386. align-items: center;
  387. }
  388. .product-left image {
  389. width: 100%;
  390. height: 386rpx;
  391. /* border-radius: 10rpx; */
  392. }
  393. .product-right {
  394. margin: 0 0 0 6rpx;
  395. display: flex;
  396. flex-direction: column;
  397. /* justify-content: space-between; */
  398. padding: 14rpx 0 5rpx;
  399. }
  400. .product-right .title {
  401. margin-left: -12px;
  402. white-space: nowrap;
  403. text-overflow: ellipsis;
  404. overflow: hidden;
  405. word-break: break-all;
  406. font-size: 36rpx;
  407. }
  408. .brief {
  409. font-size: 24rpx;
  410. margin-top: 15rpx;
  411. }
  412. .collect-detail {
  413. margin: 20rpx 0 24rpx;
  414. padding: 0 10px;
  415. background-color: #fff;
  416. }
  417. .collect-detail .van-cell {
  418. background-color: transparent;
  419. padding: 20rpx 10rpx;
  420. }
  421. .collect-detail .van-cell:after {
  422. border-bottom-color: #e4e4e4;
  423. border-bottom-width: 4rpx;
  424. left: 0;
  425. }
  426. .collect-detail .van-field__input {
  427. text-align: right;
  428. }
  429. .collect-tip {
  430. font-size: 24rpx;
  431. padding: 0 10px;
  432. }
  433. .collect-detail .van-cell__value,
  434. .collect-detail .van-field__input {
  435. color: #85868a;
  436. font-size: 24rpx;
  437. font-family: PingFangSC-Light, helvetica, 'Heiti SC';
  438. }
  439. /* 会员卡蒙层的样式 */
  440. .poster {
  441. position: fixed;
  442. top: 0;
  443. bottom: 0;
  444. right: 0;
  445. left: 0;
  446. background-color: #333333d1;
  447. /* padding: 0rpx 80rpx;
  448. padding-top: 20%;*/
  449. z-index: 9999;
  450. height: 100%;
  451. text-align: center;
  452. justify-content: center;
  453. align-items: center;
  454. display: flex;
  455. }
  456. .ads {
  457. margin: 10rpx 0rpx;
  458. color: #fff;
  459. }
  460. .tool {
  461. display: flex;
  462. text-align: center;
  463. justify-content: baseline;
  464. width: 100%;
  465. margin-top: 20rpx;
  466. }
  467. .tool view {
  468. flex: 1;
  469. }
  470. .img {
  471. width: 99rpx;
  472. }
  473. .closeImg {
  474. width: 57rpx;
  475. height: 57rpx;
  476. }
  477. .share-btn {
  478. background-color: transparent;
  479. }
  480. .share-btn::after {
  481. border: none;
  482. }
  483. .m-card {
  484. width: 100%;
  485. height: 230rpx;
  486. margin: 20rpx 0;
  487. }
  488. .m-card image {
  489. width: 100%;
  490. height: 230rpx;
  491. }
  492. </style>