index_old.vue 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953
  1. <template>
  2. <view class="page-view">
  3. <block v-if="jsonContent && jsonContent.length > 0" v-for="(item, index) in jsonContent" tid="index">
  4. <view class="ban" v-if="item.key == 'banner'">
  5. <swiper class="swiper" @change="swiperChange" autoplay="true" interval="5000" duration="300">
  6. <block v-for="(it,idx) in item.value.imageList" tid="idx">
  7. <swiper-item>
  8. <image lazy-load="true" :src="it.src" mode="aspectFill" @click="clickBanner(item)"></image>
  9. </swiper-item>
  10. </block>
  11. </swiper>
  12. <view class="dots ddflex">
  13. <block v-for="(it,idx) in item.value.imageList" tid="idx"><view :class="['dot', idx == swiperCurrent ? 'active' : '']"></view></block>
  14. </view>
  15. </view>
  16. <view class="form" v-if="item.key == 'applicationForm'">
  17. <text class="form-title" v-if="item.value.title.isShow">{{ item.value.title.value }}</text>
  18. <view class="form-list">
  19. <view class="li ddflex" v-for="(it,idx) in item.value.formItemList" tid="idx">
  20. <block v-if="it.type == 1">
  21. <!-- <input value="{{it.fieldValue}}" placeholder="{{'请填写0' + it.label}}" placeholder-class="placeholder" class="ipt fflex" if="{{it.dataType == 1}}" data-item="{{it}}" @change="changeFieldValue"/>
  22. <block else> -->
  23. <!-- if="{{isInclude(it.label, '手机')}}" -->
  24. <input
  25. v-if="it.dataType == 1"
  26. :value="it.fieldValue"
  27. :placeholder="'请填写' + it.label"
  28. placeholder-class="placeholder"
  29. maxlength="11"
  30. :data-item="it"
  31. type="tel"
  32. @change="changeFieldValue"
  33. class="ipt fflex"
  34. />
  35. <input v-else
  36. :value="it.fieldValue"
  37. :placeholder="'请填写' + it.label"
  38. placeholder-class="placeholder"
  39. class="ipt fflex"
  40. :data-item="it"
  41. @change="changeFieldValue"/>
  42. <!-- </block> -->
  43. </block>
  44. <textarea
  45. :value="it.fieldValue"
  46. :placeholder="'请填写' + it.label"
  47. placeholder-class="placeholder"
  48. class="textarea fflex"
  49. v-else-if="it.type == 4"
  50. :data-item="it"
  51. @change="changeFieldValue"
  52. ></textarea>
  53. <!-- <picker :range="it.option" class="pickers fflex" @change="changeOptions($event, idx)" v-else-if="it.type == 5">
  54. <text if="it.fieldValue">{{ it.fieldValue }}</text>
  55. <text class="placeholder" else>请选择{{ it.label }}</text>
  56. </picker> -->
  57. </view>
  58. </view>
  59. <view class="form-btn" id="view-box" @click="formSubmit(item.value)">{{ item.value.buttonName }}</view>
  60. </view>
  61. <view class="richText" v-if="item.key == 'text'">
  62. <richtext type="html">{{item.value.content}}</richtext>
  63. </view>
  64. <block v-if="item.key == 'product'">
  65. <view class="product flex-col ddflex" v-if="item.value.layoutNum == 1">
  66. <view class="li ddflex" v-for="(it,idx) in item.value.productList" tid="idx" @click="jumpUrl('/product/detail', {id:it.id})">
  67. <image :src="it.pic" mode="aspectFill" class="pro-img"></image>
  68. <view class="pro-info fflex">
  69. <text class="pro-name tovers">{{ it.title }}</text>
  70. <text class="pro-bri tover" v-if="it.brief">{{ it.brief }}</text>
  71. <view class="pro-opt ddflex">
  72. <view class="money">
  73. <text>¥{{ it.minSalePrice }}</text>
  74. <text class="texts">/起</text>
  75. </view>
  76. <text class="pro-btn">立即购买</text>
  77. </view>
  78. </view>
  79. </view>
  80. </view>
  81. <view class="product2 ddflex" v-if="item.value.layoutNum == 2">
  82. <view class="li" v-for="(it, idx) in item.value.productList" tid="idx" @click="jumpUrl('/product/detail', {id:it.id})">
  83. <image :src="it.pic" mode="aspectFill" class="pro-img"></image>
  84. <view class="pro-info fflex">
  85. <text class="pro-name tovers">{{ it.title }}</text>
  86. <view class="pro-opt ddflex">
  87. <view class="money">
  88. <text>¥{{ it.minSalePrice }}</text>
  89. <text class="texts">/起</text>
  90. </view>
  91. <view class="pro-cart"><image src="../../assets/static/pages/images/jia.png"></image></view>
  92. </view>
  93. </view>
  94. </view>
  95. </view>
  96. <view class="product product3 flex-col ddflex" v-if="item.value.layoutNum == 3">
  97. <scroll-view scroll-x="true">
  98. <view class="li" v-for="(it,idx) in item.value.productList" tid="idx" @click="jumpUrl('/product/detail', {id:it.id})">
  99. <view class="ddflex">
  100. <image :src="it.pic" mode="aspectFill" class="pro-img"></image>
  101. <view class="pro-info fflex">
  102. <text class="pro-name tovers">{{ it.title }}</text>
  103. <text class="pro-bri tover" v-if="it.brief">{{ it.brief }}</text>
  104. <view class="pro-opt ddflex">
  105. <view class="money">
  106. <text>¥{{ it.minSalePrice }}</text>
  107. <text class="texts">/起</text>
  108. </view>
  109. <text class="pro-btn">立即购买</text>
  110. </view>
  111. </view>
  112. </view>
  113. </view>
  114. </scroll-view>
  115. </view>
  116. </block>
  117. <view class="images" v-if="item.key == 'images'"><image :src="item.value.src" mode="widthFix"></image></view>
  118. <block v-if="item.key == 'customerService'">
  119. <!-- 企微客服 -->
  120. <view class="contact ddflex" @click="customerServiceChat(item.value)" v-if="item.value.type == '1'">
  121. <image src="../../assets/static/pages/images/kfico.png"></image>
  122. <text>客服</text>
  123. </view>
  124. <!-- 第三方客服 -->
  125. <view class="contact ddflex" @click="jumpHref(item.value)" v-if="item.value.type == '2'">
  126. <image src="../../static/pages/images/kfico.png"></image>客服
  127. </view>
  128. <!-- 微信客服、内置客服页面 -->
  129. <button open-type="contact" class="contact ddflex" v-if="item.value.type == '0' || item.value.type == '3'">
  130. <image src="../../assets/static/pages/images/kfico.png"></image>
  131. <text>客服</text>
  132. </button>
  133. </block>
  134. <view class="coupon flex-col ddflex" v-if="item.key == 'coupon'">
  135. <!-- <view class="tag">免费领取</view> -->
  136. <view class="form-title">
  137. <view>
  138. <text>{{ item.value.couponTitle }}</text>
  139. </view>
  140. </view>
  141. <view class="coupon-list flex-col ddflex">
  142. <view class="li flex-col ddflex" v-for="(it,indexx) in item.value.couponList" tid="indexx">
  143. <view class="info ddflex">
  144. <view class="left-pic"><image :src="it.couponIcon?it.couponIcon:'../../assets/static/pages/images/coup_logo.jpg'" mode="aspectFill"></image></view>
  145. <view class="fflex flex-col ddflex">
  146. <text class="title">{{ it.couponTitle }}</text>
  147. <text class="time">{{ getDateFormat(it.couponStart) }}-{{ getDateFormat(it.couponEnd) }}</text>
  148. </view>
  149. <view class="info-r flex-col ddflex">
  150. <view class="money">
  151. <text class="texts">¥</text>
  152. <text>{{ it.couponAmount }}</text>
  153. </view>
  154. <text class="man">{{ it.couponBrief }}</text>
  155. </view>
  156. </view>
  157. <view class="li-bot ddflex">
  158. <view class="check ddflex fflex" @click="checks(it)">
  159. <text>查看详情</text>
  160. <image v-if="!it.isShow" src="../../assets/static/pages/images/bico.png"></image>
  161. <image v-else src="../../assets/static/pages/images/bico.png" class="bico_h"></image>
  162. </view>
  163. <!-- <image src="../../static/images/ma_dark.png" class="yong-ma"></image> -->
  164. <block v-if="it.userCount >= it.userReceive && it.userCount != 0 && it.userReceive != -1">
  165. <text class="yong ddflex" @click="jumpUrl('pages/mine/coupons')">去使用</text>
  166. </block>
  167. <block v-else>
  168. <text
  169. @click="getCoupon(it)"
  170. class="yong ddflex"
  171. v-if="item.value.btnBackground.length == 2"
  172. :style="'background: linear-gradient(90deg, ' + item.value.btnBackground[0] + ' 0%, ' + item.value.btnBackground[1] + ' 100%);'"
  173. >
  174. {{ item.value.buttonName }}
  175. </text>
  176. <text
  177. @click="getCoupon(it)"
  178. class="yong ddflex"
  179. v-else-if="item.value.btnBackground.length == 1"
  180. :style="'background: ' + item.value.btnBackground[0] + ';'"
  181. >
  182. {{ item.value.buttonName }}
  183. </text>
  184. <text class="yong ddflex" v-else @click="getCoupon(it)">{{ item.value.buttonName }}</text>
  185. </block>
  186. </view>
  187. <view class="infos" v-if="it.isShow">
  188. <text>使用范围:{{ it.couponBrief }}</text>
  189. </view>
  190. </view>
  191. </view>
  192. </view>
  193. <view class="coupon flex-col ddflex" v-if="item.key == 'recharge'">
  194. <text class="tag">快捷充值</text>
  195. <view class="form-title">
  196. <view>
  197. <text>{{ item.value.rechargeTitle }}</text>
  198. </view>
  199. </view>
  200. <view class="recharge flex-col ddflex">
  201. <view :class="'dflex rechargeId' + (isInt ? ' on' : '')">
  202. <text v-if="item.value.showSymbol">¥</text>
  203. <input
  204. :placeholder="item.value.placeholderText ? item.value.placeholderText : '点击输入充值金额'"
  205. placeholder-class="placeholder"
  206. :value="pay"
  207. type="number"
  208. @change="amount"
  209. @focus="focus"
  210. />
  211. </view>
  212. <text class="rechargeMoney" v-if="TabList && TabList.length > 0">快捷充值</text>
  213. <view class="rechargeul dflex" v-if="TabList && TabList.length > 0">
  214. <!--选中 加class active -->
  215. <view :class="'rechargeli '+(it.active ?'rechargeli-active':'')" v-for="(it,index) in TabList" tid="index" @click="switchTab(it, index)">
  216. <text :class="'wealth '+ (item.active ?' awealth':'')">充{{ it.rechargeAmount }}元</text>
  217. <!-- <view class="give awealth">
  218. 送40元
  219. </view> -->
  220. </view>
  221. </view>
  222. </view>
  223. <text
  224. class="chongzhi"
  225. id="view-box"
  226. @click="remainder()"
  227. :style="item.value.mainColor ? 'background-color: ' + item.value.mainColor + ';border: 1px solid ' + item.value.mainColor + ';' : ''"
  228. >
  229. {{ item.value.buttonName }}
  230. </text>
  231. </view>
  232. </block>
  233. <block v-if="jsonContent && jsonContent.length > 0" v-for="(item,index) in jsonContent" :key="index">
  234. <block v-if="item.key == 'fixedNode'">
  235. <block v-if="item.value.type == 'applicationForm' || item.value.type == 'recharge'">
  236. <block v-if="isShowBotFixed">
  237. <view style="height: 140px;"></view>
  238. <view class="bot-fixed">
  239. <view :class="'btn'+(item.value.type == 'recharge' ? ' btn-red':'')" @click="anchor(item.value.type == 'applicationForm' ? 'form':'recharge')">{{item.value.contentObj.value.buttonName}}</view>
  240. </view>
  241. </block>
  242. </block>
  243. <block v-if="item.value.type == 'product'">
  244. <view style="height: 160px;"></view>
  245. <block v-for="(it,idx) in item.value.contentObj.value.productList" :key="idx">
  246. <view class="product-fixed ddflex" v-if="it.isFixedNode" @click="jumpUrl('pages/product/detail', {id:it.id})">
  247. <image :src="it.pic" mode="aspectFill"></image>
  248. <view class="fflex flex-col">
  249. <view class="product-tit tover">{{it.title}}</view>
  250. <view class="product-opt ddflex">
  251. <view class="product-price">
  252. <view class="product-price-m">¥{{ it.minSalePrice }}</view>
  253. <!-- <text class="product-price-t">/起</text> -->
  254. </view>
  255. <view class="product-btn">立即购买</view>
  256. </view>
  257. </view>
  258. </view>
  259. </block>
  260. </block>
  261. <block v-if="item.value.type == 'coupon'">
  262. <view style="height: 140px;"></view>
  263. <block v-for="(it,idx) in item.value.contentObj.value.couponList" :key="idx">
  264. <view class="coupon-fixed ddflex" v-if="it.isFixedNode">
  265. <image :src="it.couponIcon" mode="aspectFill" v-if="it.couponIcon"></image>
  266. <view class="fflex flex-col">
  267. <view class="title tover">{{it.couponTitle}}</view>
  268. <view class="money">
  269. <view class="texts">¥</view>
  270. <view>{{ it.couponAmount }}</view>
  271. </view>
  272. </view>
  273. <block v-if="it.userCount >= it.userReceive && it.userCount != 0 && it.userReceive != -1">
  274. <view class="yong ddflex" @click="jumpUrl('pages/mine/coupons')">去使用</view>
  275. </block>
  276. <block v-else>
  277. <view
  278. @click="getCoupon(it)"
  279. class="yong ddflex"
  280. v-if="item.value.contentObj.value.btnBackground.length == 2"
  281. :style="'background: linear-gradient(90deg, ' + item.value.contentObj.value.btnBackground[0] + ' 0%, ' + item.value.contentObj.value.btnBackground[1] + ' 100%);'"
  282. >
  283. {{ item.value.contentObj.value.buttonName }}
  284. </view>
  285. <view
  286. @click="getCoupon(it)"
  287. class="yong ddflex"
  288. v-else-if="item.value.contentObj.value.btnBackground.length == 1"
  289. :style="'background: ' + item.value.contentObj.value.btnBackground[0] + ';'"
  290. >
  291. {{ item.value.contentObj.value.buttonName }}
  292. </view>
  293. <view class="yong ddflex" v-else @click="getCoupon(it)">{{ item.value.contentObj.value.buttonName }}</view>
  294. </block>
  295. </view>
  296. </block>
  297. </block>
  298. </block>
  299. </block>
  300. <view class="mask" v-if="isShowMask"></view>
  301. <!-- <view class="guide" :style="'top:'+37+'rpx;'">
  302. <view class="guide-tit">点这里更多操作</view>
  303. <view class="guide-tip">领取优惠不迷路</view>
  304. <view class="guide-s ddflex"><image src="../../static/images/cz_jia.png"></image>添加到桌面</view>
  305. <view class="guide-s ddflex"><image src="../../static/images/cz_home.png"></image>返回首页</view>
  306. <view class="guide-btn">我知道了</view>
  307. </view> -->
  308. <view class="popupPost" v-if="isShowBMDialogView">
  309. <view class="popup flex-col ddflex" v-if="isShowBMDialogView">
  310. <image src="../../assets/static/images/popup_tip.png" class="popup-img"></image>
  311. <text class="popup-tip">提交成功</text>
  312. <text class="popup-tips">你的信息已提交,会有专业人员联系你,请耐心等待</text>
  313. <view class="popup-btns ddflex">
  314. <text class="back-home ddflex" @click="goHome()">去首页</text>
  315. <text class="check-btn ddflex" @click="hintDialogView()">确定</text>
  316. </view>
  317. <view class="popup-closePost">
  318. <image src="../../assets/static/images/popup_close.png" class="popup-close" @click="hintDialogView()"></image>
  319. </view>
  320. </view>
  321. </view>
  322. <view class="popupPost" v-if="isShowRemainderDialogView">
  323. <view class="popup flex-col ddflex" v-if="isShowRemainderDialogView">
  324. <image src="../../assets/static/images/popup_tip.png" class="popup-img"></image>
  325. <text class="popup-tip">充值成功</text>
  326. <text class="popup-tips">充值已成功,可前往“我的钱包”查看余额</text>
  327. <view class="popup-btns ddflex">
  328. <text class="back-home ddflex" @click="goHome()">去首页</text>
  329. <text class="check-btn ddflex" @click="jumpUrl('pages/wallet/index')">查看余额</text>
  330. </view>
  331. <image src="../../assets/static/images/popup_close.png" class="popup-close" @click="hintDialogView()"></image>
  332. </view>
  333. </view>
  334. <view class="popupPost" v-if="isShowCouponDialogView">
  335. <view class="popup flex-col ddflex" v-if="isShowCouponDialogView">
  336. <image src="../../assets/static/images/popup_tip.png" class="popup-img"></image>
  337. <text class="popup-tip">领取成功</text>
  338. <text class="popup-tips">已存入“我的优惠券”中,可前往查看使用</text>
  339. <view class="popup-btns ddflex">
  340. <text class="back-home ddflex" @click="jumpUrl('pages/mine/coupons')">我的优惠券</text>
  341. <text class="check-btn ddflex" @click="createCode()">立即使用</text>
  342. </view>
  343. <image src="../../assets/static/images/popup_close.png" class="popup-close" @click="hintDialogView()"></image>
  344. </view>
  345. </view>
  346. <view class="popupPost" v-if="isShowBindMobileView">
  347. <view class="popup flex-col ddflex" v-if="isShowBindMobileView">
  348. <text class="popup-tip">验证手机号</text>
  349. <text class="popup-tips">该手机号仅用于线下核销验证请放心填写</text>
  350. <input :value="phoneNumberValue" maxlength="11" type="number" placeholder="请输入手机号" placeholder-class="placeholder" class="popup-ipt" @change="phoneNumberChange" />
  351. <view class="popup-btns ddflex" style="margin-top: 60rpx">
  352. <text class="back-home ddflex" @click="hintBindMobileView()">取消</text>
  353. <text class="check-btn ddflex" @click="confirmBundMoble()">确定</text>
  354. </view>
  355. <image src="../../assets/static/images/popup_close.png" class="popup-close" @click="hintDialogView()"></image>
  356. </view>
  357. </view>
  358. <view class="ceng" v-if="isShowCard" @click="hideCardPop()"></view>
  359. <view class="qrcodePost" v-if="isShowCard">
  360. <view class="qrcode flex-col ddflex" v-if="isShowCard">
  361. <text class="hintt">{{ currentCard.couponTitle }}</text>
  362. <view class="qr-code ddflex">
  363. <image class="code-image" :src="currentCard.qrCodeUri"></image>
  364. </view>
  365. <view class="code ddflex">
  366. <text>{{ currentCard.id }}</text>
  367. <text class="copy" @click="copyCode()">复制</text>
  368. </view>
  369. <text class="hittext">- 请将二维码出示给店员核销使用 -</text>
  370. <view class="closePost">
  371. <image src="../../assets/static/pages/images/close2.png" class="close" @click="hideCardPop()"></image>
  372. </view>
  373. </view>
  374. </view>
  375. </view>
  376. </template>
  377. <script>
  378. import req from '../../utils/request.js'
  379. import util from '../../utils/util.js'
  380. import route from '../../utils/route.js'
  381. export default {
  382. data() {
  383. return {
  384. code: '',
  385. systems: {},
  386. params: '',
  387. jsonContent: '',
  388. swiperCurrent: 0,
  389. hideShare: true,
  390. codeUrl: '',
  391. sessionKey: '',
  392. openid: '',
  393. userInfo: {},
  394. isShow: false,
  395. //充值
  396. TabList: [],
  397. money: '',
  398. id: '',
  399. pay: '',
  400. active: false,
  401. isInt: false,
  402. orderId: '',
  403. checkCoupon: '', //选中的优惠券
  404. isOpenHuaweiMobile: '', //判断是否在华为上使用手机号授权
  405. isHuawei: false,
  406. isShowMask: false,
  407. isShowBMDialogView: false,
  408. isShowBindMobileView: false,
  409. phoneNumberValue: '',
  410. isShowRemainderDialogView: false,
  411. isShowCouponDialogView: false,
  412. isCoupon: false, //是否为优惠券
  413. isRemainder: false, //是否为充值
  414. //使用用券
  415. isShowCard: false,
  416. currentCard: {},
  417. ruzhuItem: '',
  418. isShowBotFixed: true,//是否显示悬浮按钮
  419. windowHeight: '',
  420. }
  421. },
  422. async onLoad(options) {
  423. console.log(options)
  424. this.code = options.code
  425. this.getAbout();
  426. await this.getParams();
  427. },
  428. async onShow() {
  429. var userInfosStr = await req.getStorage('userInfo');
  430. if (userInfosStr) {
  431. this.userInfo = userInfosStr
  432. }
  433. if (this.orderId) {
  434. let i = 0;
  435. req.loadIng();
  436. let timer = setInterval(() => {
  437. route.balanceStare(
  438. {
  439. logsId: this.orderId
  440. },
  441. res => {
  442. if (res.isSuccess || i === 4) {
  443. req.hideLoading();
  444. this.orderId = '';
  445. this.pay = '';
  446. clearInterval(timer);
  447. if (res.isSuccess) {
  448. this.showRemainderDialogView();
  449. }
  450. } else {
  451. i++;
  452. }
  453. }
  454. );
  455. }, 300);
  456. }
  457. },
  458. methods: {
  459. goHome() {
  460. this.hintDialogView();
  461. uni.navigateBack()
  462. },
  463. getAbout() {
  464. var _this = this;
  465. req.getRequest('/api/other/config', {}, function (res) {
  466. _this.isOpenHuaweiMobile = res.isOpenHuaweiMobile;
  467. });
  468. },
  469. // 余额充值
  470. async remainder() {
  471. this.isCoupon = false; //是否为优惠券
  472. this.isRemainder = true; //是否为充值
  473. if (!await req.isLogins(true)) {
  474. return;
  475. }
  476. let that = this;
  477. let from = {};
  478. if (this.pay && this.pay > 0) {
  479. from.money = this.pay;
  480. } else {
  481. return req.msg('输入的充值金额需大于0');
  482. }
  483. route.remainder(from, data => {
  484. that.orderId = data;
  485. if (!data) {
  486. return req.msg('充值下单失败');
  487. } else {
  488. route.balancePay(data, '4', that.pay, res => {
  489. if (res) {
  490. }
  491. });
  492. }
  493. });
  494. },
  495. switchTab(item, index) {
  496. this.TabList.map(it => {
  497. it.active = false;
  498. });
  499. this.TabList[index].active = true;
  500. this.pay = item.rechargeAmount;
  501. },
  502. // 输入金额根据输入金额获取赠送多少金额
  503. amount(e) {
  504. console.log('输入框中的金额>>>>', e.text);
  505. let money = e.text;
  506. this.pay = money;
  507. },
  508. focus(e) {
  509. this.isInt = true;
  510. this.TabList.map(it => {
  511. it.active = false;
  512. });
  513. },
  514. getCouponBtnText(item, name) {
  515. return item.userCount >= item.userReceive && item.userCount != 0 && item.userReceive != -1 ? '已领取' : 'name';
  516. },
  517. showBindMobileView() {
  518. this.isShowMask = true;
  519. this.isShowBindMobileView = true;
  520. },
  521. hintBindMobileView() {
  522. this.isShowMask = false;
  523. this.isShowBindMobileView = false;
  524. },
  525. showRemainderDialogView() {
  526. this.isShowMask = true;
  527. this.isShowRemainderDialogView = true;
  528. },
  529. hintRemainderDialogView() {
  530. this.isShowMask = false;
  531. this.isShowRemainderDialogView = false;
  532. },
  533. showCouponDialogView() {
  534. this.isShowMask = true;
  535. this.isShowCouponDialogView = true;
  536. },
  537. hintCouponDialogView() {
  538. this.isShowMask = false;
  539. this.isShowCouponDialogView = false;
  540. },
  541. showBMDialogView() {
  542. this.isShowMask = true;
  543. this.isShowBMDialogView = true;
  544. },
  545. hintBMDialogView() {
  546. this.isShowMask = false;
  547. this.isShowBMDialogView = false;
  548. },
  549. hintDialogView() {
  550. this.hintRemainderDialogView();
  551. this.hintBindMobileView();
  552. this.hintCouponDialogView();
  553. this.hintBMDialogView();
  554. },
  555. createCode() {
  556. if (this.currentCard) {
  557. this.isShowCard = true;
  558. } else {
  559. this.jumpUrl('pages/mine/coupons');
  560. }
  561. this.hintDialogView();
  562. },
  563. hideCardPop() {
  564. this.isShowCard = false;
  565. },
  566. copyCode() {
  567. uni.setClipboardData({
  568. data: this.currentCard.id,
  569. success: function(res) {
  570. req.msg('复制成功');
  571. }
  572. });
  573. },
  574. phoneNumberChange(ev) {
  575. this.phoneNumberValue = ev.text;
  576. },
  577. /**
  578. * 确定设置手机号
  579. */
  580. confirmBundMoble() {
  581. if (!this.phoneNumberValue) {
  582. req.msg('请输入手机号');
  583. return;
  584. }
  585. if (!util.isMobile(this.phoneNumberValue)) {
  586. req.msg('请输入11位有效手机号');
  587. return;
  588. }
  589. req.loadIng();
  590. this.bundMoble(this.phoneNumberValue);
  591. this.hintBindMobileView();
  592. },
  593. /**
  594. * 领取优惠券
  595. * @param {Object} item
  596. */
  597. async getCoupon(item) {
  598. console.log('数据>>>>>>>>', item);
  599. this.isCoupon = true; //是否为优惠券
  600. this.isRemainder = false; //是否为充值
  601. this.checkCoupon = item;
  602. if (!await req.isLogins(true)) {
  603. return;
  604. }
  605. let _ts = this;
  606. if (!_ts.userInfo.mobile) {
  607. req.getPhoneNumber(res => {
  608. _ts.bundMoble(res);
  609. });
  610. return;
  611. }
  612. this.couponReceive();
  613. },
  614. couponReceive() {
  615. var that = this;
  616. if (this.checkCoupon.userReceive > -1 && this.checkCoupon.userCount >= this.checkCoupon.userReceive) {
  617. return req.msg('您已领取过了');
  618. }
  619. req.postRequest(
  620. '/api/coupon/receive',
  621. {
  622. id: this.checkCoupon.id
  623. },
  624. res => {
  625. this.currentCard = res;
  626. console.log('领取完成>>>>', this.currentCard);
  627. this.getParams();
  628. this.showCouponDialogView();
  629. },
  630. true
  631. );
  632. },
  633. /**
  634. * 绑定手机号
  635. */
  636. bundMoble(mobile) {
  637. req.postRequest(
  638. '/api/noCode/mobile',
  639. {
  640. mobile: mobile
  641. },
  642. res => {
  643. this.isShowBindMobileView = false;
  644. this.userInfo = res;
  645. req.setStorage('userInfo', res);
  646. req.hideLoading();
  647. this.couponReceive();
  648. },
  649. true
  650. );
  651. },
  652. checks(item, index) {
  653. item.isShow = !item.isShow;
  654. this.$forceUpdate();
  655. },
  656. getParams() {
  657. let that = this;
  658. let params = {
  659. code: this.code
  660. };
  661. return new Promise((resolve, reject) => {
  662. req.getRequest(
  663. '/api/material/library/detail',
  664. params,
  665. data => {
  666. data.params.jsonContent.map(item => {
  667. if (item.key == 'applicationForm') {
  668. //表单
  669. item.value.formItemList.map(it => {
  670. if (it.label.indexOf('姓名') > -1) {
  671. if (that.userInfo.nickName) {
  672. it.fieldValue = that.userInfo.nickName;
  673. }
  674. }
  675. if (it.label.indexOf('手机') > -1) {
  676. if (that.userInfo.mobile) {
  677. it.fieldValue = that.userInfo.mobile;
  678. }
  679. }
  680. if (it.type == 4) {
  681. //备注
  682. it.fieldValue = '';
  683. }
  684. if (it.type == 5) {
  685. it.option = ['大健康', '快销品'];
  686. }
  687. });
  688. } else if (item.key == 'recharge') {
  689. //充值
  690. if (item.value.fastRechargeList && item.value.fastRechargeList.length > 0) {
  691. that.TabList = item.value.fastRechargeList.map(it => {
  692. var itm = {
  693. rechargeAmount: it,
  694. active: false
  695. };
  696. return itm;
  697. });
  698. if (that.TabList && that.TabList.length > 0) {
  699. that.TabList[0].active = true;
  700. that.pay = that.TabList[0].rechargeAmount;
  701. }
  702. console.log('TabList数据====', that.TabList);
  703. }
  704. } else if (item.key == 'coupon') {
  705. if (item.value.couponList && item.value.couponList.length > 0) {
  706. item.value.couponList.map(itx => {
  707. itx.isShow = false;
  708. return itx;
  709. })
  710. }
  711. }
  712. return item;
  713. });
  714. that.params = data;
  715. that.jsonContent = data.params.jsonContent;
  716. uni.setNavigationBarTitle({
  717. title:data.title
  718. })
  719. console.log('data.title==', data.title);
  720. console.log('data.params.jsonContent==', data.params.jsonContent);
  721. resolve();
  722. },
  723. true
  724. );
  725. });
  726. },
  727. swiperChange(e) {
  728. this.swiperCurrent = e.index;
  729. },
  730. async jumpUrl(url) {
  731. this.hintDialogView();
  732. if (await req.isLogins(true)) {
  733. uni.navigateTo({
  734. url:url
  735. })
  736. }
  737. },
  738. jumpUrlCS() {
  739. // router.push({
  740. // uri: '/pages/pagecontent',
  741. // });
  742. },
  743. customerServiceChat(item) {
  744. wx.openCustomerServiceChat({
  745. extInfo: {
  746. url: item.target
  747. },
  748. corpId: item.id,
  749. success(res) {
  750. console.log('调用微信客服')
  751. }
  752. })
  753. },
  754. jumpHref(item) {
  755. window.location.href = item.target;
  756. },
  757. isInclude(label, keytxt) {
  758. return label.indexOf(keytxt) != -1;
  759. },
  760. changeOptions(e, idx) {
  761. console.log('选择==', e);
  762. console.log('idx==', idx);
  763. this.jsonContent.map(item => {
  764. if (item.key == 'applicationForm') {
  765. item.value.formItemList.map((it, index) => {
  766. if (it.type == 5 && idx == index) {
  767. it.fieldValue = it.option[e.detail.value];
  768. }
  769. });
  770. }
  771. return item;
  772. });
  773. this.$forceUpdate();
  774. },
  775. changeFieldValue(ev) {
  776. ev._currentTarget._dataset.item.fieldValue = ev.text;
  777. },
  778. checkRequire(formItemList) {
  779. for (var i = 0; i < formItemList.length; i++) {
  780. if (formItemList[i].required) {
  781. //不等于备注,并且为空时返回
  782. if (!this.isInclude(formItemList[i].label, '备注') && !formItemList[i].fieldValue) {
  783. req.msg('请填写' + formItemList[i].label);
  784. return false;
  785. }
  786. if (formItemList[i].type == 1 && this.isInclude(formItemList[i].label, '手机')) {
  787. if (!util.isMobile(formItemList[i].fieldValue)) {
  788. req.msg('请输入11位有效手机号');
  789. return false;
  790. }
  791. }
  792. }
  793. }
  794. return true;
  795. },
  796. /**
  797. * 提交报名表单
  798. * @param {Object} datas
  799. */
  800. formSubmit(datas) {
  801. // if (!req.isLogins(true)) {
  802. // return;
  803. // }
  804. let params = {
  805. formId: datas.database
  806. };
  807. if (this.userInfo.id) {
  808. params.belongUid = this.userInfo.id;
  809. }
  810. let formItemList = datas.formItemList;
  811. let valueList = [];
  812. if (!this.checkRequire(formItemList)) return false;
  813. formItemList.map(it => {
  814. let obj = {
  815. fieldId: it.databaseLabel,
  816. fieldName: it.label,
  817. fieldType: it.type,
  818. fieldValue: it.fieldValue
  819. };
  820. valueList.push(obj);
  821. });
  822. params.valueList = valueList;
  823. console.log('表单提交==', params);
  824. req.postRequest(
  825. '/api/v3/custom/form/submit',
  826. params,
  827. data => {
  828. this.showBMDialogView();
  829. },
  830. true
  831. );
  832. },
  833. callPhone(phone) {
  834. uni.makePhoneCall({
  835. phoneNumber: phone
  836. });
  837. },
  838. // 时间格式化
  839. getDateFormat(date) {
  840. return util.formatTime(new Date(date)).t3;
  841. },
  842. anchor(id) {
  843. let that = this;
  844. let query = that.$element(id);
  845. let top = that.$element('topId');
  846. top.getBoundingClientRect({
  847. success: (data) => {
  848. query.getBoundingClientRect({
  849. success: (res) => {
  850. that.$page.scrollTo({top:res.top - data.top - 100, behavior:'smooth'})
  851. }
  852. });
  853. }
  854. });
  855. },
  856. getDevideInfo() {
  857. let that = this;
  858. device.getInfo({
  859. success: function (ret) {
  860. // px转换到rpx的比例
  861. let pxToRpxScale = 800 / ret.windowWidth;
  862. let systems = {
  863. ktxStatusHeight: ret.statusBarHeight * pxToRpxScale, // 状态栏的高度
  864. navigationHeight: 44 * pxToRpxScale // 导航栏的高度
  865. };
  866. systems.barHeight = systems.ktxStatusHeight + systems.navigationHeight;
  867. that.systems = systems;
  868. that.windowHeight = ret.windowHeight;
  869. console.log('ret==',ret)
  870. }
  871. });
  872. },
  873. },
  874. onPageScroll(e) {
  875. console.log('滚动==',e)
  876. var that = this;
  877. let query = uni.createSelectorQuery().in(this).select('#view-box');
  878. if(query){
  879. query.boundingClientRect(data=>{
  880. console.log('data==',data.top,data.height)
  881. if (data.top <= 0) {
  882. that.isShowBotFixed = true;
  883. }else if (data.top-data.height > that.windowHeight) {// 向下滑动
  884. that.isShowBotFixed = true;
  885. }else{
  886. that.isShowBotFixed = false;
  887. }
  888. }).exec();
  889. }
  890. },
  891. mounted() {
  892. const systemInfo = uni.getSystemInfoSync();
  893. // px转换到rpx的比例
  894. let pxToRpxScale = 750 / systemInfo.windowWidth;
  895. let systems = {
  896. ktxStatusHeight: systemInfo.statusBarHeight * pxToRpxScale, // 状态栏的高度
  897. navigationHeight: 44 * pxToRpxScale ,// 导航栏的高度
  898. windowHeight:systemInfo.windowHeight
  899. };
  900. this.windowHeight = systemInfo.windowHeight
  901. systems.barHeight = systems.ktxStatusHeight + systems.navigationHeight;
  902. this.systems = systems;
  903. }
  904. };
  905. </script>
  906. <style>
  907. @import './index.css';
  908. </style>