list.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  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="18" bold color="#619f8a"></u--text>
  8. </uni-col>
  9. <uni-col :span="18">
  10. <u--text :text="data.organizationName" size="18" bold color="#757575">
  11. </u--text>
  12. </uni-col>
  13. </uni-row>
  14. <view class="uni-list" style="color: #696969;margin-top: 20rpx;">
  15. <view class="uni-list-cell">
  16. <view style="padding: 20rpx;">
  17. <uni-row>
  18. <uni-col :span="20">
  19. <view v-if="addressData.userName && addressData.phone">
  20. {{addressData.userName +" "+ addressData.phone}}
  21. </view>
  22. <view v-else style="color: #bbbbbb;">
  23. 请添加或选择地址
  24. </view>
  25. <view v-if="addressData.provinces && addressData.detailedAddress">
  26. {{addressData.provinces + addressData.detailedAddress}}
  27. </view>
  28. </uni-col>
  29. <uni-col :span="4">
  30. <view class="uni-list-cell" style="text-align: center;">
  31. <view style="padding:20rpx;" @click="toAddressListPage">
  32. <image style="width: 80rpx;height: 80rpx;"
  33. src="../../static/img/page/ghAddr.png">
  34. </image>
  35. </view>
  36. </view>
  37. </uni-col>
  38. </uni-row>
  39. </view>
  40. </view>
  41. </view>
  42. <view class="uni-list" style="margin-top: 30rpx;">
  43. <view class="uni-list-cell">
  44. <view class="uni-list-cell-db">
  45. <view class="uni-input" style="color: #696969;font-size: 25rpx;font-weight: bold;">
  46. 下 单 备 注 :
  47. </view>
  48. </view>
  49. </view>
  50. <view class="uni-list-cell">
  51. <view class="uni-list-cell-db">
  52. <u--textarea v-model="remark"></u--textarea>
  53. </view>
  54. </view>
  55. </view>
  56. </view>
  57. <u-list @scrolltolower="scrolltolower">
  58. <view v-if="!shopDataNow">
  59. <image style="margin: 0 auto; width: 100%;" src="../../static/img/page/empty_view.png"></image>
  60. </view>
  61. <u-list-item v-for="(item, index) in shopDataNow" :key="index">
  62. <view v-if="item.num !== 0 && item.num" class="listItemStyle">
  63. <u-row>
  64. <u-col span="3">
  65. <u--image :showLoading="true" shape="circle" :src="baseURL+item.giftPictrue"
  66. width="70px" height="70px" style="margin: 10px;"></u--image>
  67. </u-col>
  68. <u-col span="9" class="">
  69. <view>
  70. {{item.giftName}}
  71. </view>
  72. <u-row>
  73. <u-col span="10">
  74. <view style="margin-top: 3px;">
  75. <u-icon name="integral" :label="item.giftPrice"></u-icon>
  76. </view>
  77. </u-col>
  78. <u-col span="2">
  79. <view style="margin-top: 3px;">
  80. x {{parseInt(item.num)}}
  81. </view>
  82. </u-col>
  83. </u-row>
  84. </u-col>
  85. <!-- <u-col span="1" class="numberStyler">
  86. <view style="padding: 15rpx;">
  87. <u-button icon="minus" size="mini" color="#e93c45" @click="addToCart(0,item)">
  88. </u-button>
  89. </view>
  90. <view style="padding: 15rpx;">
  91. <u-button icon="plus" size="mini" color="rgb(10, 185, 156)"
  92. @click="addToCart(1,item)">
  93. </u-button>
  94. </view>
  95. </u-col> -->
  96. <!-- <u-col span="1">
  97. <u-button @click="addToCart(0,item)" icon="trash" size="30" color="#d23226">
  98. </u-button>
  99. </u-col> -->
  100. </u-row>
  101. </view>
  102. </u-list-item>
  103. </u-list>
  104. <view style="margin-bottom: 220rpx;"></view>
  105. </view>
  106. <view class="bottim_view">
  107. <view>
  108. <u-row>
  109. <u-col span="7">
  110. <view class="sum_price_view">
  111. <span>合计:</span>
  112. <u-row>
  113. <u-col span="3">
  114. <u-icon name="integral" color="#aa0000" size="30"></u-icon>
  115. </u-col>
  116. <u-col span="9">
  117. <view style="margin-left: 20rpx;color:#aa0000;font-size: 40rpx;">
  118. {{priceSum}}
  119. </view>
  120. </u-col>
  121. </u-row>
  122. </view>
  123. </u-col>
  124. <u-col span="5">
  125. <u-button class="btnDoPay" shape="circle" @click="toOKPage"
  126. color="linear-gradient(to bottom right, #79a7a4, #88d8a1)" text="确认支付"></u-button>
  127. </u-col>
  128. </u-row>
  129. </view>
  130. </view>
  131. </view>
  132. </template>
  133. <script>
  134. export default {
  135. data() {
  136. return {
  137. ghAddrSrc: '',
  138. index: 0,
  139. baseURL: this.$BASE_URL,
  140. priceSum: 0.0,
  141. dateShow: false,
  142. data: {
  143. organizationName: "",
  144. },
  145. jcd: [],
  146. from: {
  147. userNumber: '',
  148. phone: '',
  149. jgid: '',
  150. paytime: '',
  151. orderTotal: 0,
  152. hsGifts: [],
  153. remark: '',
  154. placeNumber: ''
  155. },
  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.getAddress()
  191. },
  192. onshow() {
  193. console.log("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 getAddress() {
  206. if (uni.getStorageSync("addressData")) {
  207. this.addressData = uni.getStorageSync("addressData")
  208. return
  209. }
  210. const {
  211. data: res
  212. } = await this.$httpRequest({
  213. url: '/app/uadsList?userCode=' + uni.getStorageSync('userInfo').userName,
  214. method: 'get',
  215. urlType: 2
  216. });
  217. if (res.code === 200) {
  218. this.addressData = res.rows[0]
  219. } else {
  220. uni.showToast({
  221. duration: 2500,
  222. title: res.msg,
  223. icon: 'error',
  224. });
  225. }
  226. },
  227. bindPickerChange: function(e) {
  228. console.log('picker发送选择改变,携带值为', e.detail.value)
  229. this.index = e.detail.value
  230. },
  231. addToCartOLD(type, food) {
  232. food.num -= 1
  233. this.priceSum = parseFloat(this.priceSum) - parseFloat(food.giftPrice)
  234. let coyp = []
  235. this.shopDataNow.forEach(item => {
  236. if (item.num != 0) {
  237. coyp.push(item)
  238. }
  239. })
  240. this.shopDataNow = coyp
  241. },
  242. addToCart(type, gift) {
  243. if (type === 0 && gift.num === 0) {
  244. return
  245. }
  246. if (gift.amount === 0) {
  247. uni.showToast({
  248. duration: 500,
  249. title: "库存不足",
  250. icon: 'error'
  251. });
  252. return
  253. }
  254. if (type === 1) {
  255. if (gift.num) {
  256. if (gift.amount <= gift.num) {
  257. uni.showToast({
  258. duration: 500,
  259. title: "库存已达最大数量",
  260. icon: 'error'
  261. });
  262. return
  263. }
  264. gift.num += 1
  265. } else {
  266. gift.num = 1
  267. }
  268. this.priceSum = parseFloat(this.priceSum) + gift.giftPrice + ''
  269. } else {
  270. gift.num -= 1
  271. this.priceSum = parseFloat(this.priceSum) - gift.giftPrice + ''
  272. }
  273. // let that = this
  274. // setTimeout(() => {
  275. // that.setGwcNum()
  276. // }, 100)
  277. },
  278. toOKPage() {
  279. let that = this
  280. uni.requestSubscribeMessage({
  281. tmplIds: ['kVkzFr0kqRMg_bHA9WPE8SU-udtMh452g0GRE2a03qU'],
  282. success(res) {
  283. that.submitOrder()
  284. },
  285. fail() {
  286. that.submitOrder()
  287. }
  288. })
  289. },
  290. async submitOrder() {
  291. const data = this.shopDataNow
  292. for (var i = 0; i < data.length; i++) {
  293. if (data[i].num) {
  294. data[i].amount = data[i].num
  295. }
  296. }
  297. this.from = {
  298. userNumber: this.addressData.userCode,
  299. userName: this.addressData.userName,
  300. phone: this.addressData.phone,
  301. jgid: uni.getStorageSync("orgInfo").organizationCode,
  302. paytime: '',
  303. orderTotal: this.priceSum,
  304. hsGifts: this.shopDataNow,
  305. remark: this.remark,
  306. placeNumber: this.addressData.provinces + this.addressData.detailedAddress
  307. }
  308. if (this.priceSum === 0) {
  309. uni.showToast({
  310. duration: 1500,
  311. icon: 'none',
  312. title: "没有需要兑换的物品"
  313. });
  314. return
  315. }
  316. // 发送请求
  317. const {
  318. data: res
  319. } = await this.$httpRequest({
  320. url: '/app/giftOrder',
  321. method: 'post',
  322. data: this.from,
  323. urlType: 2
  324. });
  325. if (res.code === 200) {
  326. this.priceSum = 0.0;
  327. uni.navigateTo({
  328. url: 'ok'
  329. })
  330. } else {
  331. uni.showToast({
  332. duration: 1500,
  333. title: res.msg,
  334. icon: 'none'
  335. });
  336. }
  337. },
  338. submitDate() {},
  339. scrolltolower() {
  340. //this.getRechargeHistoryList()
  341. },
  342. loadmore(data) {
  343. for (var i = 0; i < data.length; i++) {
  344. this.indexList.push(data[i])
  345. }
  346. },
  347. result(time, mode) {
  348. const timeFormat = uni.$u.timeFormat
  349. switch (mode) {
  350. case 'datetime':
  351. return timeFormat(time, 'yyyy-mm-dd hh:MM')
  352. case 'date':
  353. return timeFormat(time, 'yyyy-mm-dd')
  354. case 'year-month':
  355. return timeFormat(time, 'yyyy-mm')
  356. case 'time':
  357. return time
  358. default:
  359. return ''
  360. }
  361. }
  362. }
  363. }
  364. </script>
  365. <style lang="scss" scoped>
  366. .view {
  367. background-color: #ebebeb;
  368. padding-top: 10px;
  369. }
  370. .hand {
  371. padding: 5%;
  372. margin: 0 5px 5px 5px;
  373. border-radius: 15px;
  374. background: linear-gradient(to bottom right, #97dad8, #f1fef9);
  375. }
  376. .orgTop {
  377. margin-bottom: 5px;
  378. }
  379. .sxButton {
  380. width: 100px;
  381. display: flex;
  382. flex-direction: column;
  383. align-items: center;
  384. }
  385. .listTermDate {
  386. padding: 10px 0;
  387. }
  388. .listItemStyle {
  389. margin: 5px 12px;
  390. padding: 5px;
  391. border-radius: 15px;
  392. background-color: #fafafa;
  393. }
  394. .minus {
  395. width: 22px;
  396. height: 22px;
  397. background-color: #efefef;
  398. border-width: 1px;
  399. border-color: #c6c6c6;
  400. border-radius: 100px;
  401. display: flex;
  402. justify-content: center;
  403. align-items: center;
  404. }
  405. .input {
  406. padding: 0;
  407. }
  408. .plus {
  409. width: 22px;
  410. height: 22px;
  411. background-color: #FF0000;
  412. border-radius: 50%;
  413. /* #ifndef APP-NVUE */
  414. display: flex;
  415. /* #endif */
  416. justify-content: center;
  417. align-items: center;
  418. }
  419. .numberStyler {
  420. position: relative;
  421. left: -10px;
  422. }
  423. .bottim_view {
  424. padding: 5px 20px 30px;
  425. position: fixed;
  426. left: 0px;
  427. bottom: 0px;
  428. width: 100%;
  429. height: 80px;
  430. background-color: #ffffff;
  431. z-index: 9999;
  432. }
  433. .sum_price_num_style {
  434. font-size: 30px;
  435. color: #d83024;
  436. }
  437. .sum_price_view {
  438. margin-left: 10px;
  439. display: flex;
  440. justify-content: unset;
  441. align-items: baseline;
  442. }
  443. .btnDoPay {
  444. width: 100%;
  445. }
  446. </style>