list.vue 11 KB

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