list.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  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. </u-col>
  122. <u-col span="5">
  123. <u-button class="btnDoPay" shape="circle" @click="toOKPage" :disabled="isDisabled"
  124. color="linear-gradient(to bottom right, #79a7a4, #88d8a1)" text="确认支付"></u-button>
  125. </u-col>
  126. </u-row>
  127. </view>
  128. </view>
  129. </view>
  130. </template>
  131. <script>
  132. export default {
  133. data() {
  134. return {
  135. ghAddrSrc: '',
  136. index: 0,
  137. baseURL: this.$BASE_URL,
  138. priceSum: 0.0,
  139. dateShow: false,
  140. data: {
  141. organizationName: "",
  142. },
  143. jcd: [],
  144. from: {
  145. userNumber: '',
  146. phone: '',
  147. jgid: '',
  148. paytime: '',
  149. orderTotal: 0,
  150. hsGifts: [],
  151. remark: '',
  152. placeNumber: ''
  153. },
  154. isDisabled: false,
  155. placeData: [],
  156. shopData: [],
  157. shopDataNow: [],
  158. addressData: uni.getStorageSync("addressData"),
  159. remark: ''
  160. }
  161. },
  162. onBackPress() {
  163. uni.removeStorageSync('shopData')
  164. this.priceSum = 0.0
  165. },
  166. onShow() {
  167. this.shopDataNow = []
  168. this.data.organizationName = uni.getStorageSync("orgInfo").organizationName
  169. //清空价格总数
  170. this.priceSum = 0;
  171. //获取瀑布流中所有菜品数据
  172. const data = uni.getStorageSync('shopData')
  173. for (var i = 0; i < data.length; i++) {
  174. if (data[i].num) {
  175. //计算单个菜品的总价格
  176. const total = data[i].num * data[i].giftPrice
  177. data[i].total = total
  178. //传入 购物数据当前集合
  179. this.shopDataNow.push(data[i])
  180. //计算页面显示的总价格
  181. this.priceSum = parseFloat(this.priceSum) + (data[i].num * parseFloat(data[i].giftPrice)) + ''
  182. }
  183. }
  184. //获取菜品查询数据
  185. const cuisinesData = uni.getStorageSync("cuisinesData")
  186. //获取用户信息
  187. const user = uni.getStorageSync('userInfo');
  188. },
  189. onLoad() {
  190. this.getGiftReceivePlace()
  191. // this.getAddress()
  192. },
  193. onshow() {
  194. this.getAddress()
  195. },
  196. methods: {
  197. toAddressListPage() {
  198. uni.redirectTo({
  199. url: '../../pageA/card/addressList',
  200. success() {
  201. uni.setStorageSync("clickType", 1)
  202. }
  203. })
  204. },
  205. async getGiftReceivePlace() {
  206. const {
  207. data: res
  208. } = await this.$httpRequest({
  209. url: '/app/getGiftReceivePlace',
  210. method: 'get',
  211. urlType: this.$getUrlType()
  212. });
  213. if (res.code === 200) {
  214. this.placeData = res.data
  215. } else {
  216. uni.showModal({
  217. title: "系统提醒",
  218. showCancel: false,
  219. content: res.msg,
  220. });
  221. }
  222. },
  223. async getAddress() {
  224. if (uni.getStorageSync("addressData")) {
  225. this.addressData = uni.getStorageSync("addressData")
  226. return
  227. }
  228. const {
  229. data: res
  230. } = await this.$httpRequest({
  231. url: '/app/uadsList?userCode=' + uni.getStorageSync('userInfo').userName,
  232. method: 'get',
  233. urlType: 2
  234. });
  235. if (res.code === 200) {
  236. this.addressData = res.rows[0]
  237. } else {
  238. uni.showToast({
  239. duration: 2500,
  240. title: res.msg,
  241. icon: 'error',
  242. });
  243. }
  244. },
  245. bindPickerChange: function(e) {
  246. this.index = e.detail.value
  247. },
  248. addToCartOLD(type, food) {
  249. food.num -= 1
  250. this.priceSum = parseFloat(this.priceSum) - parseFloat(food.giftPrice)
  251. let coyp = []
  252. this.shopDataNow.forEach(item => {
  253. if (item.num != 0) {
  254. coyp.push(item)
  255. }
  256. })
  257. this.shopDataNow = coyp
  258. },
  259. addToCart(type, gift) {
  260. if (type === 0 && gift.num === 0) {
  261. return
  262. }
  263. if (gift.amount === 0) {
  264. uni.showToast({
  265. duration: 500,
  266. title: "库存不足",
  267. icon: 'error'
  268. });
  269. return
  270. }
  271. if (type === 1) {
  272. if (gift.num) {
  273. if (gift.amount <= gift.num) {
  274. uni.showToast({
  275. duration: 500,
  276. title: "库存已达最大数量",
  277. icon: 'error'
  278. });
  279. return
  280. }
  281. gift.num += 1
  282. } else {
  283. gift.num = 1
  284. }
  285. this.priceSum = parseFloat(this.priceSum) + gift.giftPrice + ''
  286. } else {
  287. gift.num -= 1
  288. this.priceSum = parseFloat(this.priceSum) - gift.giftPrice + ''
  289. }
  290. // let that = this
  291. // setTimeout(() => {
  292. // that.setGwcNum()
  293. // }, 100)
  294. },
  295. toOKPage() {
  296. this.isDisabled = true
  297. let that = this
  298. that.submitOrder()
  299. },
  300. async submitOrder() {
  301. uni.showLoading({
  302. title: '加载中',
  303. mask: true
  304. })
  305. const data = this.shopDataNow
  306. for (var i = 0; i < data.length; i++) {
  307. if (data[i].num) {
  308. data[i].amount = data[i].num
  309. }
  310. }
  311. let userInfo = uni.getStorageSync('userInfo')
  312. this.from = {
  313. userNumber: userInfo.userName,
  314. userName: userInfo.nickName,
  315. phone: userInfo.phonenumber,
  316. jgid: uni.getStorageSync("orgInfo").organizationCode,
  317. paytime: '',
  318. orderType: uni.getStorageSync('orderType'),
  319. orderTotal: this.priceSum,
  320. hsGifts: this.shopDataNow,
  321. remark: this.remark,
  322. placeNumber: this.placeData[this.index].placeName
  323. }
  324. if (this.priceSum === 0) {
  325. uni.showToast({
  326. duration: 1500,
  327. icon: 'none',
  328. title: "没有需要兑换的物品"
  329. });
  330. return
  331. }
  332. // 发送请求
  333. const {
  334. data: res
  335. } = await this.$httpRequest({
  336. url: '/app/giftOrder',
  337. method: 'post',
  338. data: this.from,
  339. urlType: this.$getUrlType()
  340. });
  341. if (res.code === 200) {
  342. this.priceSum = 0.0;
  343. setTimeout(() => {
  344. uni.hideLoading()
  345. this.isDisabled = false
  346. uni.navigateTo({
  347. url: 'ok'
  348. })
  349. }, 1000)
  350. } else {
  351. uni.hideLoading()
  352. this.isDisabled = false
  353. uni.showToast({
  354. duration: 1500,
  355. title: res.msg,
  356. icon: 'none'
  357. });
  358. }
  359. },
  360. submitDate() {},
  361. scrolltolower() {
  362. //this.getRechargeHistoryList()
  363. },
  364. loadmore(data) {
  365. for (var i = 0; i < data.length; i++) {
  366. this.indexList.push(data[i])
  367. }
  368. },
  369. result(time, mode) {
  370. const timeFormat = uni.$u.timeFormat
  371. switch (mode) {
  372. case 'datetime':
  373. return timeFormat(time, 'yyyy-mm-dd hh:MM')
  374. case 'date':
  375. return timeFormat(time, 'yyyy-mm-dd')
  376. case 'year-month':
  377. return timeFormat(time, 'yyyy-mm')
  378. case 'time':
  379. return time
  380. default:
  381. return ''
  382. }
  383. }
  384. }
  385. }
  386. </script>
  387. <style lang="scss" scoped>
  388. .view {
  389. background-color: #ebebeb;
  390. padding-top: 10px;
  391. }
  392. .hand {
  393. padding: 5%;
  394. margin: 0 5px 5px 5px;
  395. border-radius: 15px;
  396. background: linear-gradient(to bottom right, #97dad8, #f1fef9);
  397. }
  398. .orgTop {
  399. margin-bottom: 5px;
  400. }
  401. .sxButton {
  402. width: 100px;
  403. display: flex;
  404. flex-direction: column;
  405. align-items: center;
  406. }
  407. .listTermDate {
  408. padding: 10px 0;
  409. }
  410. .listItemStyle {
  411. margin: 5px 12px;
  412. padding: 5px;
  413. border-radius: 15px;
  414. background-color: #fafafa;
  415. }
  416. .minus {
  417. width: 22px;
  418. height: 22px;
  419. background-color: #efefef;
  420. border-width: 1px;
  421. border-color: #c6c6c6;
  422. border-radius: 100px;
  423. display: flex;
  424. justify-content: center;
  425. align-items: center;
  426. }
  427. .input {
  428. padding: 0;
  429. }
  430. .plus {
  431. width: 22px;
  432. height: 22px;
  433. background-color: #FF0000;
  434. border-radius: 50%;
  435. /* #ifndef APP-NVUE */
  436. display: flex;
  437. /* #endif */
  438. justify-content: center;
  439. align-items: center;
  440. }
  441. .numberStyler {
  442. position: relative;
  443. left: -10px;
  444. }
  445. .bottim_view {
  446. padding: 5px 20px 30px;
  447. position: fixed;
  448. left: 0px;
  449. bottom: 0px;
  450. width: 100%;
  451. height: 80px;
  452. background-color: #ffffff;
  453. z-index: 9999;
  454. }
  455. .sum_price_num_style {
  456. font-size: 30px;
  457. color: #d83024;
  458. }
  459. .sum_price_view {
  460. margin-left: 10px;
  461. display: flex;
  462. justify-content: unset;
  463. align-items: baseline;
  464. }
  465. .btnDoPay {
  466. width: 100%;
  467. }
  468. </style>