index.jsx 6.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. import Taro from "@tarojs/taro";
  2. import { useState, useEffect } from "react";
  3. import withLayout from "@/layouts";
  4. import CustomNav from "@/components/CustomNav";
  5. import { getShopDetail, getShopPackage, getExtendContent } from '@/services/home'
  6. import Popup from "@/components/Popup";
  7. import LocationBig from "@/assets/icons/UserCenter/LocationBig.png";
  8. import Perfection from "@/assets/icons/UserCenter/Perfection.png";
  9. import Check_OK from "@/assets/icons/UserCenter/Check_OK.png";
  10. import Check_NO from "@/assets/icons/UserCenter/Check_NO.png";
  11. import BlackSpot from "@/assets/icons/GuideCheck/BlackSpot.png";
  12. import image from "@/assets/icons/ProCard/8kb.jpg";
  13. import food from "@/assets/icons/ProCard/food.png";
  14. import ProCard_hot from "@/assets/icons/ProCard/ProCard_hot.png";
  15. import { Button, Icon, Text, Textarea } from "@tarojs/components";
  16. import { getVerifyTargetList, putVerifyTarget } from "@/services/payOrder";
  17. import formatTime from '@/utils/formatTime'
  18. import "./style.less";
  19. export default withLayout((props) => {
  20. const { router, person } = props;
  21. console.log("🚀 ~ file: index.jsx ~ line 22 ~ withLayout ~ props", props)
  22. const { id, subOrderId } = props.router.params;
  23. const [showDialog, setShowDialog] = useState(false);
  24. //核销
  25. const [Consumption, setConsumption] = useState(false);
  26. const [checked, setChecked] = useState();
  27. const [shopContent, setShopContent] = useState([])
  28. const [list, setList] = useState([]);
  29. const getShop = () => {
  30. getShopDetail(id).then(e => {
  31. setShopContent(e)
  32. })
  33. }
  34. const getList = (params) => {
  35. getVerifyTargetList({
  36. shopId: id,
  37. isMine: true,
  38. isVerified: 0,
  39. pageNum: 1,
  40. pageSize: 50,
  41. }).then((res) => {
  42. if (res) {
  43. setList(res.records)
  44. setChecked(res?.records.filter(x => x.subOrderId == subOrderId)[0]?.verifyNo)
  45. // if(item.verifyNo==checked)
  46. }
  47. });
  48. };
  49. useEffect(() => {
  50. getList();
  51. getShop();
  52. }, []);
  53. const ShowMoldeOn = () => {
  54. setShowDialog(true);
  55. };
  56. const ButtonCancel = () => {
  57. setShowDialog(false);
  58. };
  59. const ButtonOK = (e) => {
  60. if (!checked) return
  61. // setShowDialog(false)
  62. if (showDialog === true) {
  63. Taro.showLoading({
  64. title: '核销中'
  65. })
  66. putVerifyTarget(checked).then(res => {
  67. Taro.hideLoading()
  68. setShowDialog(false);
  69. setConsumption(true);
  70. }).catch(e => {
  71. Taro.hideLoading()
  72. setShowDialog(false);
  73. Taro.showToast({
  74. title: '核销失败',
  75. icon: 'none',
  76. duration: 2000
  77. })
  78. })
  79. }
  80. };
  81. const PerfectionOK = () => {
  82. setConsumption(false);
  83. if (list?.length > 1) {
  84. getList()
  85. } else {
  86. Taro.navigateBack({ delta: 1 })
  87. }
  88. };
  89. return (
  90. <view className="shop-Eat">
  91. <CustomNav title="到店核销" />
  92. <Popup show={showDialog} maskClosable={false}>
  93. <view className="Consumption-Now">您即将核销1张套餐券!</view>
  94. <text className="Consumption-text">核销后套餐券不退不换</text>
  95. <text className="Consumption-text">请核对无误后再点击确认!</text>
  96. <view className="buy-button-box">
  97. <button className="button-Cancel" onClick={ButtonCancel}>
  98. 取消
  99. </button>
  100. <button className="button-OK" onClick={ButtonOK}>
  101. 确定
  102. </button>
  103. </view>
  104. </Popup>
  105. <Popup show={Consumption} maskClosable={false}>
  106. <view className="Perfection-image-view">
  107. <image src={Perfection} className="Perfection-image" />
  108. </view>
  109. <text>核销完成!请与店铺确认!</text>
  110. <view className="buy-button-box">
  111. <button className="button-OK" onClick={PerfectionOK}>
  112. 完成
  113. </button>
  114. </view>
  115. </Popup>
  116. <view>
  117. <view className="position-header">
  118. <image className="position-LocationBig" src={LocationBig} />
  119. <text cla="position-LocationBig-text">
  120. 当前所在店铺:{shopContent?.shopName || []}
  121. </text>
  122. </view>
  123. <view className="shop-image">
  124. <image
  125. mode="scaleToFill"
  126. className="shop-title-image-cup"
  127. src={BlackSpot}
  128. />
  129. <text className="shop-title-title">请选择你要核销的套餐</text>
  130. </view>
  131. <view>
  132. {(list||[]).map((item) => {
  133. return (
  134. <view class="wrapper" key={item.verifyNo} onClick={() => setChecked(item.verifyNo)}>
  135. <view class="left-complete-one">
  136. <view className="Check_OK-box">
  137. <image className="Check_OK-image" src={item.verifyNo == checked ? Check_OK : Check_NO} />
  138. </view>
  139. <image className="left-image-1" src={ProCard_hot}></image>
  140. <view className="left-viewText">返现¥{item.cashback}</view>
  141. <view className="title-image">
  142. <image
  143. className="image-1"
  144. mode="scaleToFill"
  145. src={item.poster}
  146. ></image>
  147. <image className="image-2" src={food}></image>
  148. </view>
  149. <view className="title-content">
  150. <view className="Pro-title">
  151. <view className="title-text">
  152. {item.description}
  153. <text className="title-money-2">数量:1张</text>
  154. </view>
  155. </view>
  156. <text className="title-money">
  157. ¥{item.actualPrice / 100}元<text className="title-money-2">门市价{item.standPrice / 100}元</text>
  158. </text>
  159. <view className="title-time">
  160. 有效期:{formatTime(item?.createDate, "yyyy/MM/dd")}-
  161. {formatTime(item?.expireDate, "yyyy/MM/dd")}
  162. </view>
  163. </view>
  164. </view>
  165. <view class="right-complete-two">
  166. <view className="right-content"></view>
  167. </view>
  168. </view>
  169. );
  170. })}
  171. </view>
  172. <view className="button-info">
  173. <Button className="button-box" disabled={!checked} onClick={ShowMoldeOn}>
  174. 确定核销
  175. </Button>
  176. </view>
  177. </view>
  178. </view>
  179. );
  180. });