selectProduct.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434
  1. <template>
  2. <view class="content">
  3. <image style="width: 35rpx;height: 35rpx;position: absolute;right: 40rpx;top:40rpx" @click="closeSelectProduct"
  4. src="@/static/points/closeIcon.png" mode=""></image>
  5. <view class="addressBox">
  6. <image style="width: 40rpx;height: 40rpx;" src="@/static/points/addressIcon.png" mode=""></image>
  7. <text class="name" v-if="defaultAddress">{{ defaultAddress.userName }}</text>
  8. <text class="address" v-if="defaultAddress">{{ defaultAddress.address + defaultAddress.atlasAdd
  9. }}</text>
  10. <view style="position: absolute;right: 0;display: flex;width: 195rpx;align-items: center;height: 33rpx;
  11. ">
  12. <text class="address" style="color: #999;" v-if='!defaultAddress'>添加收货地址</text>
  13. <image style="width: 35rpx;height: 35rpx;position: absolute;right: 0;top: 0;" @click="addressSelectFun"
  14. src="@/static/points/Keyboard_arrow_rifht.png" mode=""></image>
  15. </view>
  16. </view>
  17. <view class="productPrice">
  18. <view style="display:flex;justify-content: space-between;">
  19. <view style="display:flex;">
  20. <view style="display: flex;align-items: center;">
  21. <image v-if="selectedObj" style="width: 120rpx;height: 120rpx;"
  22. :src="$globalData.publicUrl + selectedObj.image" mode="heightFix">
  23. </image>
  24. <image v-else style="width: 120rpx;height: 120rpx;"
  25. :src="$globalData.publicUrl + params.productMainImage" mode="">
  26. </image>
  27. </view>
  28. <view
  29. style="margin-left: 24rpx;display: flex;flex-direction: column;justify-content: space-between;">
  30. <view class="price" v-if="selectedObj">实付价
  31. {{ params.paymentType == 1 ? selectedObj.pricePoint + '积分' :
  32. params.paymentType == 2 ? '¥' + selectedObj.priceMoney + '元' :
  33. params.paymentType == 3 ? '¥' + selectedObj.priceMoney + '元' + '+' +
  34. selectedObj.pricePoint + '积分' : null }}
  35. </view>
  36. <view class="price" v-else>实付价
  37. {{ params.paymentType == 1 ? params.pricePoint + '积分' :
  38. params.paymentType == 2 ? '¥' + params.priceMoney + '元' :
  39. params.paymentType == 3 ? '¥' + params.priceMoney + '元' + '+' +
  40. params.pricePoint + '积分' : null }}
  41. </view>
  42. <view class="spec" v-if="selectedObj">已选:{{ selectedObj.specValueText }} </view>
  43. </view>
  44. </view>
  45. <view class="deletePrice" v-if="selectedObj">{{ selectedObj.originPrice }}元</view>
  46. </view>
  47. </view>
  48. <!--选择规格 -->
  49. <view class="specClass">
  50. <view v-for="arr in specList">
  51. <view class="title">{{ arr[0] }} ({{ Array.from(arr[1]).length }})</view>
  52. <view style="display: flex;flex-wrap: wrap;">
  53. <view class="specCombination" @click="selectedSpecFun(value, arr[0])"
  54. :class="selectedObj ? selectedObj.specValueText.indexOf(value) != -1 ? 'active' : '' : ''"
  55. v-for="value in Array.from(arr[1])">
  56. {{ value }}
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. <!--运费 -->
  62. <view class="yunFeiClass">
  63. <view class="text">运费</view>
  64. <view class="price">¥{{ params.freight }}</view>
  65. </view>
  66. <!--订单备注 -->
  67. <view class="nodeClass">
  68. <view class="text">订单备注</view>
  69. <input type="text" maxlength="200" v-model="orderRemarks" placeholder="选填,请填写您的备注信息,限200字" />
  70. </view>
  71. <!--支付方式 -->
  72. <u-radio-group v-if="selectPayMeth" class="nodeClass" v-model="selectPayMeth">
  73. <view style="width: 100%;">
  74. <view style="display: flex;justify-content: space-between;width: 100%;">
  75. <view style="display: flex;">
  76. <image style="width: 40rpx;height: 40rpx;" src="@/static/points/weiXin.png" mode="">
  77. </image>
  78. <view class="text" style="color: #333;margin-left: 16rpx;">微信支付</view>
  79. </view>
  80. <view>
  81. <u-radio activeColor="#03C1B8 " name='1' style="margin: 0;"></u-radio>
  82. </view>
  83. </view>
  84. <view style="display: flex;justify-content: space-between;width: 100%;margin-top: 24rpx;">
  85. <view style="display: flex;">
  86. <image style="width: 40rpx;height: 40rpx;" src="@/static/points/yue.png" mode="">
  87. </image>
  88. <view class="text" style="color: #333;margin-left: 16rpx;">余额支付</view>
  89. </view>
  90. <u-radio activeColor="#03C1B8 " name='2'></u-radio>
  91. </view>
  92. </view>
  93. </u-radio-group>
  94. <view class="footer-bar">
  95. <u-button v-if="!selectedObj" :customStyle="{
  96. color: '#fff',
  97. background: '#03C1B8'
  98. }">请选择</u-button>
  99. <u-button :disabled="redeemNowBtnDisable" v-else-if="selectedObj && selectedObj.stock" :customStyle="{
  100. color: '#fff',
  101. background: '#03C1B8'
  102. }" @click="redeemNowFun">实付价 {{ params.paymentType == 1 ? selectedObj.pricePoint + '积分' :
  103. params.paymentType == 2 ? '¥' + selectedObj.priceMoney + '元' :
  104. params.paymentType == 3 ? '¥' + selectedObj.priceMoney + '元' + '+' +
  105. selectedObj.pricePoint + '积分' : null }}</u-button>
  106. <u-button v-else-if="selectedObj.stock === 0" :customStyle="{
  107. color: '#999999 ',
  108. background: '#eee'
  109. }">库存不足</u-button>
  110. </view>
  111. </view>
  112. </template>
  113. <script>
  114. export default {
  115. components: {},
  116. props: {
  117. params: {
  118. type: Object,
  119. default: {}
  120. },
  121. defaultAddress: {
  122. type: Object,
  123. default: null
  124. },
  125. redeemNowBtnDisable: {
  126. type: Boolean,
  127. default: false
  128. },
  129. },
  130. data() {
  131. return {
  132. orderRemarks: '',
  133. selectPayMeth: '1',
  134. reasonRefusal: '',
  135. showPopup: false,
  136. specValueText: '',
  137. specValuePrice: '',
  138. specList: [],
  139. selectedObj: null,
  140. }
  141. },
  142. onLoad(data) {
  143. console.log('555')
  144. },
  145. onShow() {
  146. console.log('555')
  147. this.$emit('getAddrListFun')
  148. },
  149. onPageScroll() {
  150. },
  151. create() {
  152. console.log('55522')
  153. },
  154. computed: {
  155. // specValuePrice() {
  156. // return ;
  157. // }
  158. },
  159. methods: {
  160. //
  161. onShowFun(selectedObj, orderRemarks, selectPayMeth) {
  162. if (orderRemarks) this.orderRemarks = orderRemarks
  163. if (selectPayMeth) this.selectPayMeth = selectPayMeth
  164. if (selectedObj) {
  165. this.selectedObj = JSON.parse(JSON.stringify(selectedObj))
  166. } else {
  167. this.selectedObj = this.params.specComboVOList[0]
  168. }
  169. const map = new Map();
  170. this.params.specComboVOList.forEach(item => {
  171. item.specNameValueList.forEach(spec => {
  172. const key = spec.specName;
  173. if (!map.has(key)) {
  174. map.set(key, new Set());
  175. }
  176. map.get(key).add(spec.specValue);
  177. });
  178. })
  179. this.specList = Array.from(map)
  180. },
  181. //立即兑换
  182. redeemNowFun() {
  183. this.$emit('redeemNowFun', this.selectedObj ? JSON.parse(JSON.stringify(this.selectedObj)) : null, this.selectPayMeth, this.orderRemarks, true)
  184. },
  185. //点击选规则
  186. selectedSpecFun(specValue, specName) {
  187. if (this.selectedObj) {
  188. let selectedObj = JSON.parse(JSON.stringify(this.selectedObj))
  189. let specValueT
  190. selectedObj.specNameValueList.forEach((e, i) => {
  191. if (e.specName == specName) {
  192. specValueT = e.specValue
  193. }
  194. })
  195. selectedObj.specValues.forEach((r, n) => {
  196. if (r == specValueT) {
  197. selectedObj.specValues.splice(n, 1)
  198. }
  199. })
  200. this.params.specComboVOList.forEach((item, index) => {
  201. if (item.specValueText.indexOf(specValue) != -1 && item.specValueText.indexOf(selectedObj.specValues.toString()) != -1) {
  202. this.selectedObj = item
  203. }
  204. })
  205. }
  206. //console.log(this.selectedObj, 'this.selectedObj')
  207. //console.log(specValue, specName, 'value,specName')
  208. },
  209. //关闭选择商品页
  210. closeSelectProduct() {
  211. this.$emit('closeSelectProduct', this.selectedObj ? JSON.parse(JSON.stringify(this.selectedObj)) : null, this.selectPayMeth, this.orderRemarks)
  212. },
  213. //去我的地址页面
  214. addressSelectFun() {
  215. uni.navigateTo({
  216. url: `/pages/address/index?selectedAddressId=${this.defaultAddress?this.defaultAddress.id:null}`
  217. });
  218. }
  219. }
  220. }
  221. </script>
  222. <style lang="scss" scoped>
  223. .content {
  224. background-color: #F5F8F8;
  225. padding: 24rpx 32rpx 32rpx 32rpx;
  226. font-family: PingFang SC, PingFang SC;
  227. height: 1000rpx;
  228. border-radius: 20rpx 20rpx 0 0;
  229. overflow-y: auto;
  230. position: relative;
  231. .addressBox {
  232. position: relative;
  233. margin-top: 70rpx;
  234. display: flex;
  235. align-items: center;
  236. border-radius: 20rpx 20rpx 20rpx 20rpx;
  237. .name {
  238. margin: 0 24rpx;
  239. font-weight: 500;
  240. font-size: 32rpx;
  241. color: #333333;
  242. line-height: 40rpx;
  243. text-align: left;
  244. font-style: normal;
  245. text-transform: none;
  246. }
  247. .address {
  248. font-weight: 500;
  249. font-size: 28rpx;
  250. color: #333333;
  251. text-align: left;
  252. font-style: normal;
  253. text-transform: none;
  254. width: 460rpx;
  255. white-space: nowrap;
  256. overflow: hidden;
  257. text-overflow: ellipsis;
  258. }
  259. }
  260. .productPrice {
  261. background-color: #fff;
  262. margin-top: 24rpx;
  263. padding: 24rpx;
  264. border-radius: 20rpx 20rpx 20rpx 20rpx;
  265. .price {
  266. font-weight: bold;
  267. font-size: 28rpx;
  268. color: #03C1B8;
  269. text-align: left;
  270. font-style: normal;
  271. text-transform: none;
  272. }
  273. .spec {
  274. font-weight: 500;
  275. font-size: 26rpx;
  276. color: #999999;
  277. text-align: left;
  278. font-style: normal;
  279. text-transform: none;
  280. }
  281. .deletePrice {
  282. font-weight: 500;
  283. font-size: 32rpx;
  284. color: #666666;
  285. text-align: left;
  286. font-style: normal;
  287. text-decoration-line: line-through;
  288. text-transform: none;
  289. }
  290. }
  291. .specClass {
  292. background-color: #fff;
  293. margin-top: 24rpx;
  294. padding: 0 24rpx 24rpx 24rpx;
  295. border-radius: 20rpx 20rpx 20rpx 20rpx;
  296. .title {
  297. padding-top: 24rpx;
  298. font-weight: bold;
  299. font-size: 28rpx;
  300. color: #333333;
  301. text-align: left;
  302. font-style: normal;
  303. text-transform: none;
  304. }
  305. .specCombination {
  306. font-weight: 500;
  307. font-size: 24rpx;
  308. color: #666666;
  309. text-align: left;
  310. font-style: normal;
  311. text-transform: none;
  312. height: 56rpx;
  313. background: #F0F0F0;
  314. border-radius: 38rpx 38rpx 38rpx 38rpx;
  315. margin-right: 16rpx;
  316. padding: 8rpx 16rpx;
  317. margin-top: 24rpx;
  318. }
  319. .active {
  320. background: #03C1B8;
  321. border-radius: 38rpx 38rpx 38rpx 38rpx;
  322. color: #fff;
  323. }
  324. }
  325. .yunFeiClass {
  326. display: flex;
  327. justify-content: space-between;
  328. height: 92rpx;
  329. background: #FFFFFF;
  330. border-radius: 20rpx 20rpx 20rpx 20rpx;
  331. margin-top: 24rpx;
  332. align-items: center;
  333. padding: 24rpx;
  334. .text {
  335. font-weight: 500;
  336. font-size: 28rpx;
  337. color: #666666;
  338. line-height: 40rpx;
  339. text-align: left;
  340. font-style: normal;
  341. text-transform: none;
  342. }
  343. }
  344. ::v-deep .nodeClass {
  345. margin-top: 24rpx;
  346. padding: 24rpx;
  347. background: #FFFFFF;
  348. border-radius: 20rpx 20rpx 20rpx 20rpx;
  349. display: flex;
  350. align-items: center;
  351. justify-content: space-between;
  352. margin-bottom: 30rpx;
  353. .u-radio__icon-wrap {
  354. margin: 0;
  355. }
  356. .text {
  357. width: 115rpx;
  358. font-weight: 500;
  359. font-size: 28rpx;
  360. color: #666666;
  361. line-height: 40rpx;
  362. text-align: left;
  363. }
  364. input {
  365. font-weight: 500;
  366. font-size: 26rpx;
  367. color: #999999;
  368. line-height: 40rpx;
  369. text-align: right;
  370. font-style: normal;
  371. text-transform: none;
  372. width: 450rpx;
  373. }
  374. }
  375. }
  376. .footer-bar {
  377. .u-button {
  378. width: 670rpx;
  379. height: 84rpx;
  380. border-radius: 98rpx 98rpx 98rpx 98rpx;
  381. margin: 20rpx 40rpx;
  382. background: '#000';
  383. }
  384. }
  385. </style>