list.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493
  1. <template>
  2. <view>
  3. <view class="view">
  4. <view class="hand">
  5. <uni-row>
  6. <uni-col :span="6">
  7. <u--text text="所属机构" size="16" bold color="#619f8a"></u--text>
  8. </uni-col>
  9. <uni-col :span="18">
  10. <u--text :text="data.organizationName" size="16" color="#757575">
  11. </u--text>
  12. </uni-col>
  13. </uni-row>
  14. <view style="color: #696969;margin-top: 20rpx;">
  15. <uni-row>
  16. <uni-col :span="7">
  17. <u--text text="领取地点" size="16" bold color="#619f8a"></u--text>
  18. </uni-col>
  19. <uni-col :span="12">
  20. <view>
  21. <view style="padding: 0 20rpx;">
  22. <picker @change="bindPickerChange" :value="index" :range="placeData"
  23. range-key="placeName">
  24. <view style="font-size: 40rpx;color: #848484;"
  25. v-if="placeData[index].placeName">
  26. <u--text :iconStyle="{color: '#757575',fontSize:'40rpx'}"
  27. suffixIcon="arrow-down" :text="placeData[index].placeName"
  28. color="#757575" size="16"></u--text>
  29. </view>
  30. </picker>
  31. </view>
  32. </view>
  33. </uni-col>
  34. </uni-row>
  35. </view>
  36. <view class="uni-list" style="margin-top: 30rpx;">
  37. <view class="uni-list-cell">
  38. <view class="uni-list-cell-db">
  39. <view class="uni-input" style="color: #535353;font-size: 25rpx;">
  40. 下单备注:
  41. </view>
  42. </view>
  43. </view>
  44. <view class="uni-list-cell">
  45. <view class="uni-list-cell-db">
  46. <u--textarea v-model="remark"></u--textarea>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. <u-list @scrolltolower="scrolltolower">
  52. <view v-if="!shopDataNow">
  53. <image style="margin: 0 auto; width: 100%;" src="../../static/img/page/empty_view.png"></image>
  54. </view>
  55. <u-list-item v-for="(item, index) in shopDataNow" :key="index">
  56. <view v-if="item.num !== 0 && item.num" class="listItemStyle">
  57. <u-row>
  58. <u-col span="3">
  59. <u--image :showLoading="true" shape="circle" :src="baseURL+item.giftPictrue"
  60. width="70px" height="70px" style="margin: 10px;"></u--image>
  61. </u-col>
  62. <u-col span="9" class="">
  63. <view>
  64. {{item.giftName}}
  65. </view>
  66. <view v-if="item.eventTime"
  67. style="text-align: left;color: #ffaf25;font-size: 22rpx;margin-top: 10rpx;">
  68. {{item.eventTime+" 可领取"}}
  69. </view>
  70. <u-row>
  71. <u-col span="10">
  72. <view style="margin-top: 3px;">
  73. <u-icon name="integral" :label="item.giftPrice"></u-icon>
  74. </view>
  75. </u-col>
  76. <u-col span="2">
  77. <view style="margin-top: 3px;">
  78. x {{parseInt(item.num)}}
  79. </view>
  80. </u-col>
  81. </u-row>
  82. </u-col>
  83. <!-- <u-col span="1" class="numberStyler">
  84. <view style="padding: 15rpx;">
  85. <u-button icon="minus" size="mini" color="#e93c45" @click="addToCart(0,item)">
  86. </u-button>
  87. </view>
  88. <view style="padding: 15rpx;">
  89. <u-button icon="plus" size="mini" color="rgb(10, 185, 156)"
  90. @click="addToCart(1,item)">
  91. </u-button>
  92. </view>
  93. </u-col> -->
  94. <!-- <u-col span="1">
  95. <u-button @click="addToCart(0,item)" icon="trash" size="30" color="#d23226">
  96. </u-button>
  97. </u-col> -->
  98. </u-row>
  99. </view>
  100. </u-list-item>
  101. </u-list>
  102. <view style="margin-bottom: 220rpx;"></view>
  103. </view>
  104. <view class="bottim_view">
  105. <view>
  106. <u-row>
  107. <u-col span="7">
  108. <view class="sum_price_view">
  109. <span>合计</span>
  110. <u-row>
  111. <u-col span="3">
  112. <u-icon name="integral" color="#aa0000" size="30"></u-icon>
  113. </u-col>
  114. <u-col span="9">
  115. <view style="margin-left: 20rpx;color:#aa0000;font-size: 40rpx;">
  116. {{priceSum}}
  117. </view>
  118. </u-col>
  119. </u-row>
  120. </view>
  121. <view class="sum_price_view">
  122. <span>可用余额</span>
  123. <u-row>
  124. <u-col span="2">
  125. <u-icon name="integral" color="#000000" size="20"></u-icon>
  126. </u-col>
  127. <u-col span="10">
  128. <view style="margin-left: 5rpx;color:#000000;font-size: 35rpx;">
  129. {{dqye}}
  130. </view>
  131. </u-col>
  132. </u-row>
  133. </view>
  134. </u-col>
  135. <u-col span="5">
  136. <u-button class="btnDoPay" shape="circle" @click="toOKPage" :disabled="isDisabled"
  137. color="linear-gradient(to bottom right, #79a7a4, #88d8a1)" text="确认支付"></u-button>
  138. </u-col>
  139. </u-row>
  140. </view>
  141. </view>
  142. </view>
  143. </template>
  144. <script>
  145. export default {
  146. data() {
  147. return {
  148. ghAddrSrc: '',
  149. index: 0,
  150. baseURL: this.$BASE_URL,
  151. priceSum: 0.0,
  152. dateShow: false,
  153. data: {
  154. organizationName: "",
  155. },
  156. dqye: uni.getStorageSync('userInfo').integral,
  157. jcd: [],
  158. from: {
  159. userNumber: '',
  160. phone: '',
  161. jgid: '',
  162. paytime: '',
  163. orderTotal: 0,
  164. hsGifts: [],
  165. remark: '',
  166. placeNumber: ''
  167. },
  168. isDisabled: false,
  169. placeData: [],
  170. shopData: [],
  171. shopDataNow: [],
  172. addressData: uni.getStorageSync("addressData"),
  173. remark: ''
  174. }
  175. },
  176. onBackPress() {
  177. uni.removeStorageSync('shopData')
  178. this.priceSum = 0.0
  179. },
  180. onShow() {
  181. this.shopDataNow = []
  182. this.data.organizationName = uni.getStorageSync("orgInfo").organizationName
  183. //清空价格总数
  184. this.priceSum = 0;
  185. //获取瀑布流中所有菜品数据
  186. const data = uni.getStorageSync('shopData')
  187. for (var i = 0; i < data.length; i++) {
  188. if (data[i].num) {
  189. //计算单个菜品的总价格
  190. const total = data[i].num * data[i].giftPrice
  191. data[i].total = total
  192. //传入 购物数据当前集合
  193. this.shopDataNow.push(data[i])
  194. //计算页面显示的总价格
  195. this.priceSum = parseFloat(this.priceSum) + (data[i].num * parseFloat(data[i].giftPrice)) + ''
  196. }
  197. }
  198. //获取菜品查询数据
  199. const cuisinesData = uni.getStorageSync("cuisinesData")
  200. //获取用户信息
  201. const user = uni.getStorageSync('userInfo');
  202. },
  203. onLoad() {
  204. this.getGiftReceivePlace()
  205. // this.getAddress()
  206. },
  207. onshow() {
  208. this.getAddress()
  209. },
  210. methods: {
  211. toAddressListPage() {
  212. uni.redirectTo({
  213. url: '../../pageA/card/addressList',
  214. success() {
  215. uni.setStorageSync("clickType", 1)
  216. }
  217. })
  218. },
  219. async getGiftReceivePlace() {
  220. const {
  221. data: res
  222. } = await this.$httpRequest({
  223. url: '/app/getGiftReceivePlace',
  224. method: 'get',
  225. urlType: this.$getUrlType()
  226. });
  227. if (res.code === 200) {
  228. this.placeData = res.data
  229. } else {
  230. uni.showModal({
  231. title: "系统提醒",
  232. showCancel: false,
  233. content: res.msg,
  234. });
  235. }
  236. },
  237. async getAddress() {
  238. if (uni.getStorageSync("addressData")) {
  239. this.addressData = uni.getStorageSync("addressData")
  240. return
  241. }
  242. const {
  243. data: res
  244. } = await this.$httpRequest({
  245. url: '/app/uadsList?userCode=' + uni.getStorageSync('userInfo').userName,
  246. method: 'get',
  247. urlType: 2
  248. });
  249. if (res.code === 200) {
  250. this.addressData = res.rows[0]
  251. } else {
  252. uni.showToast({
  253. duration: 2500,
  254. title: res.msg,
  255. icon: 'error',
  256. });
  257. }
  258. },
  259. bindPickerChange: function(e) {
  260. this.index = e.detail.value
  261. },
  262. addToCartOLD(type, food) {
  263. food.num -= 1
  264. this.priceSum = parseFloat(this.priceSum) - parseFloat(food.giftPrice)
  265. let coyp = []
  266. this.shopDataNow.forEach(item => {
  267. if (item.num != 0) {
  268. coyp.push(item)
  269. }
  270. })
  271. this.shopDataNow = coyp
  272. },
  273. addToCart(type, gift) {
  274. if (type === 0 && gift.num === 0) {
  275. return
  276. }
  277. if (gift.amount === 0) {
  278. uni.showToast({
  279. duration: 500,
  280. title: "库存不足",
  281. icon: 'error'
  282. });
  283. return
  284. }
  285. if (type === 1) {
  286. if (gift.num) {
  287. if (gift.amount <= gift.num) {
  288. uni.showToast({
  289. duration: 500,
  290. title: "库存已达最大数量",
  291. icon: 'error'
  292. });
  293. return
  294. }
  295. gift.num += 1
  296. } else {
  297. gift.num = 1
  298. }
  299. this.priceSum = parseFloat(this.priceSum) + gift.giftPrice + ''
  300. } else {
  301. gift.num -= 1
  302. this.priceSum = parseFloat(this.priceSum) - gift.giftPrice + ''
  303. }
  304. // let that = this
  305. // setTimeout(() => {
  306. // that.setGwcNum()
  307. // }, 100)
  308. },
  309. toOKPage() {
  310. this.isDisabled = true
  311. let that = this
  312. that.submitOrder()
  313. },
  314. async submitOrder() {
  315. uni.showLoading({
  316. title: '加载中',
  317. mask: true
  318. })
  319. const data = this.shopDataNow
  320. for (var i = 0; i < data.length; i++) {
  321. if (data[i].num) {
  322. data[i].amount = data[i].num
  323. }
  324. }
  325. let userInfo = uni.getStorageSync('userInfo')
  326. this.from = {
  327. userNumber: userInfo.userName,
  328. userName: userInfo.nickName,
  329. phone: userInfo.phonenumber,
  330. jgid: uni.getStorageSync("orgInfo").organizationCode,
  331. paytime: '',
  332. orderType: uni.getStorageSync('orderType'),
  333. orderTotal: this.priceSum,
  334. hsGifts: this.shopDataNow,
  335. remark: this.remark,
  336. placeNumber: this.placeData[this.index].placeName
  337. }
  338. if (this.priceSum === 0) {
  339. uni.showToast({
  340. duration: 1500,
  341. icon: 'none',
  342. title: "没有需要兑换的物品"
  343. });
  344. return
  345. }
  346. // 发送请求
  347. const {
  348. data: res
  349. } = await this.$httpRequest({
  350. url: '/app/giftOrder',
  351. method: 'post',
  352. data: this.from,
  353. urlType: this.$getUrlType()
  354. });
  355. if (res.code === 200) {
  356. this.priceSum = 0.0;
  357. setTimeout(() => {
  358. uni.hideLoading()
  359. this.isDisabled = false
  360. uni.navigateTo({
  361. url: 'ok'
  362. })
  363. }, 1000)
  364. } else {
  365. uni.hideLoading()
  366. this.isDisabled = false
  367. this.$showModal(res.msg)
  368. }
  369. },
  370. submitDate() {},
  371. scrolltolower() {
  372. //this.getRechargeHistoryList()
  373. },
  374. loadmore(data) {
  375. for (var i = 0; i < data.length; i++) {
  376. this.indexList.push(data[i])
  377. }
  378. },
  379. result(time, mode) {
  380. const timeFormat = uni.$u.timeFormat
  381. switch (mode) {
  382. case 'datetime':
  383. return timeFormat(time, 'yyyy-mm-dd hh:MM')
  384. case 'date':
  385. return timeFormat(time, 'yyyy-mm-dd')
  386. case 'year-month':
  387. return timeFormat(time, 'yyyy-mm')
  388. case 'time':
  389. return time
  390. default:
  391. return ''
  392. }
  393. }
  394. }
  395. }
  396. </script>
  397. <style lang="scss" scoped>
  398. .view {
  399. background-color: #ebebeb;
  400. padding-top: 10px;
  401. }
  402. .hand {
  403. padding: 5%;
  404. margin: 0 5px 5px 5px;
  405. border-radius: 15px;
  406. background: linear-gradient(to bottom right, #97dad8, #f1fef9);
  407. }
  408. .orgTop {
  409. margin-bottom: 5px;
  410. }
  411. .sxButton {
  412. width: 100px;
  413. display: flex;
  414. flex-direction: column;
  415. align-items: center;
  416. }
  417. .listTermDate {
  418. padding: 10px 0;
  419. }
  420. .listItemStyle {
  421. margin: 5px 12px;
  422. padding: 5px;
  423. border-radius: 15px;
  424. background-color: #fafafa;
  425. }
  426. .minus {
  427. width: 22px;
  428. height: 22px;
  429. background-color: #efefef;
  430. border-width: 1px;
  431. border-color: #c6c6c6;
  432. border-radius: 100px;
  433. display: flex;
  434. justify-content: center;
  435. align-items: center;
  436. }
  437. .input {
  438. padding: 0;
  439. }
  440. .plus {
  441. width: 22px;
  442. height: 22px;
  443. background-color: #FF0000;
  444. border-radius: 50%;
  445. /* #ifndef APP-NVUE */
  446. display: flex;
  447. /* #endif */
  448. justify-content: center;
  449. align-items: center;
  450. }
  451. .numberStyler {
  452. position: relative;
  453. left: -10px;
  454. }
  455. .bottim_view {
  456. padding: 5px 20px 30px;
  457. position: fixed;
  458. left: 0px;
  459. bottom: 0px;
  460. width: 100%;
  461. height: 110px;
  462. background-color: #ffffff;
  463. z-index: 9999;
  464. }
  465. .sum_price_num_style {
  466. font-size: 30px;
  467. color: #d83024;
  468. }
  469. .sum_price_view {
  470. margin-left: 10px;
  471. // display: flex;
  472. justify-content: unset;
  473. align-items: baseline;
  474. }
  475. .btnDoPay {
  476. width: 100%;
  477. }
  478. </style>