waitOrderDetail.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443
  1. <template>
  2. <view class="order-pages">
  3. <view class="order-info">
  4. <!-- 订单状态 -->
  5. <view class="order-status">
  6. <view class="status-title flex align_center justify_center">
  7. <u-icon class="icon" name="icon_service"
  8. custom-prefix="custom-icon" size="48" color="#333333"></u-icon>
  9. {{orderInfo.orderStatusDictValue || '--'}}
  10. </view>
  11. <view class="status-care">
  12. 预约时间:{{orderInfo.reserveTime || '--'}}
  13. </view>
  14. </view>
  15. <!-- 回收品类明细 -->
  16. <view class="item-info">
  17. <view class="item-title">
  18. <view>回收品类明细</view>
  19. <view class="care">(切换分类可输入不同回收物的价格和重量)</view>
  20. </view>
  21. <view class="item flex justify_between">
  22. <view :class="['item-type', curType == item.code ? 'active' : '']" v-for="(item,index) in typeData" :key="item.id" @click="getRow(item.code,index)">
  23. {{item.dispName}}
  24. </view>
  25. </view>
  26. <view class="table">
  27. <view>单价(元/kg)</view>
  28. <view>重量(kg)</view>
  29. <view>合计金额(元)</view>
  30. </view>
  31. <view v-if="list.length && list[curIndex].typeList.length" v-for="item in list[curIndex].typeList" :key="item.id" class="item flex justify_between align_center">
  32. <view class="flex align_center">
  33. <text class="item-name">{{item.name}}</text>
  34. <u-input type="digit" @input="numberToFixed(item,'customerPrice',2)" :custom-style="inputLeftStyle" input-align="center" :clearable="false" v-model="item.customerPrice" placeholder="输入单价" />
  35. </view>
  36. <view class="flex flex_1 align_center">
  37. <u-input type="digit" @input="numberToFixed(item,'rubbishWeight',2)" :custom-style="inputRightStyle" input-align="center" :clearable="false" v-model="item.rubbishWeight" placeholder="请输入重量" />
  38. </view>
  39. <view class="flex_1 flex align_center justify_center">{{item.totalAmount}}</view>
  40. </view>
  41. </view>
  42. <!-- 金额 -->
  43. <view class="item-info">
  44. <view class="item flex justify_between">
  45. <text>应付金额</text>
  46. <text>{{originalAmount}} 元</text>
  47. </view>
  48. <view class="item flex justify_between">
  49. <text>支付方式</text>
  50. <v-select class="flex_1" ref="payType" :disabled="true" placeholder="请选择支付方式" @itemChange="chooseType" code="ORDER_RESERVE_PAY_TYPE" style="width: 100%"></v-select>
  51. </view>
  52. </view>
  53. <!-- 服务信息 -->
  54. <view class="info-main flex flex_column">
  55. <view class="flex flex_1 align_center">
  56. <view class="new-left ellipsis-two">
  57. {{orderInfo.contactAddress}}
  58. </view>
  59. </view>
  60. <view class="time flex align_center justify_between">
  61. <text>{{orderInfo.contactName}}</text>
  62. <view @click="callPhone(orderInfo.contactMobile)" class="flex align_center">
  63. <u-icon class="phone" name="icon_phone" custom-prefix="custom-icon" size="28" color="#999999"></u-icon>
  64. <text>{{orderInfo.contactMobile}}</text>
  65. </view>
  66. </view>
  67. </view>
  68. </view>
  69. <view class="footer">
  70. <u-button @click="submit" :loading="loading" class="flex_1" type="primary">提交</u-button>
  71. </view>
  72. </view>
  73. </template>
  74. <script>
  75. import moment from 'moment'
  76. import { orderDetailFind, orderSubmit } from '@/api/order.js'
  77. import { getLookUpDatas } from '@/api/data.js'
  78. import { reservePriceFind } from '@/api/index.js'
  79. import vSelect from '@/components/select/v-select.vue'
  80. import {numberToFixed} from '@/libs/tools.js'
  81. export default {
  82. components: {
  83. vSelect
  84. },
  85. data() {
  86. return {
  87. orderInfo: {},
  88. totalPrice: 0, // 支付合计
  89. orderReserveNo: '', // 订单号
  90. inputLeftStyle: {
  91. Width: '110rpx',
  92. borderBottom: '1px solid #707070',
  93. padding: '0rpx 10rpx',
  94. color: '#191919'
  95. },
  96. inputRightStyle:{
  97. padding: '0rpx 10rpx',
  98. color: '#191919'
  99. },
  100. curType: '', // 当前类型
  101. curIndex: 0, // 当前类型index
  102. typeData: [], // 垃圾类型数据
  103. list: [],
  104. payType: '', // 支付方式
  105. loading: false
  106. }
  107. },
  108. onLoad(options) {
  109. if (options.orderNo) {
  110. console.log(options.orderNo)
  111. this.orderReserveNo = options.orderNo
  112. this.getOrderDetail()
  113. this.getRubbishType()
  114. }
  115. // 开启分享
  116. uni.showShareMenu({
  117. withShareTicket: true,
  118. menus: ['shareAppMessage', 'shareTimeline']
  119. })
  120. },
  121. computed: {
  122. // 支付总金额
  123. originalAmount() {
  124. let total = 0
  125. if(this.list.length){
  126. this.list.map(item =>{
  127. item.typeList.map(k =>{
  128. total = total + (k.customerPrice*k.rubbishWeight)
  129. })
  130. })
  131. }
  132. return total.toFixed(2)
  133. },
  134. // 总重量
  135. totalWeight() {
  136. let total = 0
  137. if(this.list.length){
  138. this.list.map(item =>{
  139. item.typeList.map(k =>{
  140. total = total + k.rubbishWeight
  141. })
  142. })
  143. }
  144. return total
  145. }
  146. },
  147. methods: {
  148. // 小数点后两位
  149. numberToFixed: function (item,key, num) {
  150. let val = item[key]
  151. let ret = numberToFixed(val, num, 999999)
  152. this.$nextTick(() => {
  153. item[key] = Number(ret)
  154. item.totalAmount = (item.customerPrice * item.rubbishWeight).toFixed(2)
  155. })
  156. },
  157. // 打电话
  158. callPhone(phone) {
  159. uni.makePhoneCall({
  160. phoneNumber: phone
  161. });
  162. },
  163. // 获取订单详情
  164. getOrderDetail() {
  165. uni.showLoading({
  166. title: '加载中...'
  167. })
  168. orderDetailFind({
  169. orderReserveNo: this.orderReserveNo
  170. }).then(res => {
  171. console.log(res,'rrrrrrrr')
  172. if (res.status == 200 && res.data) {
  173. this.orderInfo = res.data
  174. this.orderInfo.reserveTime = moment(this.orderInfo.confirmDate).format('YYYY-MM-DD') + this.orderInfo.reserveTimeTypeDictValue
  175. }
  176. uni.hideLoading()
  177. })
  178. },
  179. // 获取垃圾类型数据
  180. getRubbishType() {
  181. this.list = []
  182. getLookUpDatas({type:'RESERVE_RUBBISH_TYPE'}).then(res=>{
  183. if(res.status == 200) {
  184. this.typeData = res.data || []
  185. this.typeData.map(k =>{
  186. let p = {
  187. typeCode: k.code,
  188. typeList: []
  189. }
  190. console.log(p,'pppppp')
  191. this.list.push(p)
  192. })
  193. // console.log(this.list,'this.list----------')
  194. this.curType = this.typeData.length ? this.typeData[0].code : ''
  195. this.curIndex = 0
  196. this.getRow()
  197. } else {
  198. this.typeData = []
  199. }
  200. })
  201. },
  202. // 查询列表
  203. getRow(code,num) {
  204. this.curType = code || this.curType
  205. this.curIndex = num || 0
  206. if(this.list[this.curIndex].typeList.length) return
  207. reservePriceFind({code:this.curType}).then(res => {
  208. if (res.status == 200) {
  209. let data = res.data
  210. data.forEach(item =>{
  211. item.rubbishWeight = ''
  212. item.totalAmount = ''
  213. })
  214. this.list[this.curIndex].typeList = data
  215. // console.log(this.list,'----this.list')
  216. } else {
  217. this.list[this.curIndex].typeList = []
  218. this.total = 0
  219. this.noDataText = res.message
  220. }
  221. })
  222. },
  223. // 选择支付方式
  224. chooseType(code) {
  225. this.payType = code
  226. console.log(this.payType,'this.payType')
  227. },
  228. // 提交
  229. submit() {
  230. // uni.redirectTo({
  231. // url: '/pages/order/finish?money=' + 12
  232. // })
  233. // return
  234. let arr = []
  235. this.list.map(item =>{
  236. item.typeList.map(k =>{
  237. if(k.rubbishWeight) {
  238. let p = {
  239. rubbishType: item.typeCode, //垃圾大类型
  240. rubbishTypeItem: k.code, // 垃圾细分类型
  241. rubbishWeight: k.rubbishWeight*1000, // 垃圾重量(克)
  242. rubbishPrice: k.customerPrice, // 单价
  243. totalAmount: k.rubbishWeight* k.customerPrice // 总价金额
  244. }
  245. arr.push(p)
  246. }
  247. })
  248. })
  249. if(arr.length==0) {
  250. uni.showToast({
  251. title: '请先输入重量,总重大于0!',
  252. icon: 'none'
  253. })
  254. return
  255. }
  256. if (!this.payType) {
  257. uni.showToast({
  258. title: '请选择支付方式!',
  259. icon: 'none'
  260. })
  261. return
  262. }
  263. let params = {
  264. "payType": this.payType, //支付方式
  265. originalAmount: this.originalAmount, // 支付总金额
  266. totalWeight: this.totalWeight*1000, // 总重量(g)
  267. contactName: this.orderInfo.contactName, //联系人姓名
  268. contactMobile: this.orderInfo.contactMobile, //联系人手机号
  269. contactAddress: this.orderInfo.contactAddress,//联系人地址
  270. orderReserveNo: this.orderReserveNo,
  271. orderReserveItemEntityList: arr
  272. }
  273. this.loading = true
  274. orderSubmit(params).then(res=>{
  275. if(res.status == 200) {
  276. uni.showToast({
  277. title: res.message,
  278. icon: 'none'
  279. })
  280. uni.redirectTo({
  281. url: '/pages/order/finish?money=' + res.data
  282. })
  283. }
  284. this.loading = false
  285. })
  286. }
  287. },
  288. }
  289. </script>
  290. <style lang="scss">
  291. .order-pages {
  292. width: 100%;
  293. height: 100vh;
  294. display: flex;
  295. flex-direction: column;
  296. background-color: #F5F5F5;
  297. .order-info {
  298. width: 100%;
  299. flex: 1;
  300. overflow-y: scroll;
  301. // 订单内容
  302. .info-main{
  303. background: #ffffff;
  304. padding: 10upx 32upx;
  305. margin: 20upx 32upx;
  306. border-radius: 24upx;
  307. box-shadow: 1px 1px 3px #EEEEEE;
  308. font-size: 28upx;
  309. background-image: url(../../static/order_bg_stor.png);
  310. background-repeat: no-repeat;
  311. background-size: contain;
  312. height: 260rpx;
  313. .new-left{
  314. width: 360rpx;
  315. font-size: 36rpx;
  316. color: #191919;
  317. font-weight: 600;
  318. line-height: 44rpx;
  319. margin-top: 30rpx;
  320. }
  321. .time{
  322. padding: 20rpx 0;
  323. font-size: 32rpx;
  324. color: #7C7D7E;
  325. margin-top: 20rpx;
  326. view:last-child{
  327. font-size: 28rpx;
  328. color: #4C4C4C;
  329. margin-left: 6rpx;
  330. }
  331. }
  332. }
  333. // 状态
  334. .order-status {
  335. padding: 30upx 0;
  336. text-align: center;
  337. .status-title {
  338. font-size: 42upx;
  339. color: #191919;
  340. .icon{
  341. width: 48rpx;
  342. height: 48rpx;
  343. margin-right: 10rpx;
  344. }
  345. }
  346. .status-care {
  347. font-size: 28upx;
  348. margin-top: 10upx;
  349. color: #191919;
  350. >text {
  351. color: red;
  352. }
  353. }
  354. }
  355. // 订单信息列
  356. .item-info{
  357. border-radius: 24rpx;
  358. margin: 0rpx 32rpx 20rpx;
  359. padding: 0rpx 32rpx;
  360. background-color: #fff;
  361. .item-title{
  362. font-size: 32rpx;
  363. color: #181818;
  364. padding-top: 28rpx;
  365. .care{
  366. font-size: 24rpx;
  367. color: #FF2C5C;
  368. margin-top: 10rpx;
  369. }
  370. }
  371. .table{
  372. padding: 20rpx 0;
  373. display: flex;
  374. font-size: 28rpx;
  375. view{
  376. width: 33%;
  377. text-align: center;
  378. }
  379. }
  380. .item{
  381. padding: 28rpx 0;
  382. font-size: 32rpx;
  383. border-bottom: 1px solid #EBEBEB;
  384. .item-name{
  385. max-width: 100rpx;
  386. font-size: 30rpx;
  387. }
  388. :first-child{
  389. color: #7C7D7E;
  390. }
  391. :last-child-child{
  392. color: #222222;
  393. }
  394. &:last-child{
  395. border-bottom: none;
  396. }
  397. .input-left{
  398. padding: 6rpx;
  399. border-bottom: 1px solid #707070;
  400. }
  401. .item-type{
  402. padding: 10rpx 14rpx;
  403. border: 1px solid #979797;
  404. opacity: 1;
  405. border-radius: 30rpx;
  406. font-size: 30rpx;
  407. color: #999999;
  408. text-align: center;
  409. }
  410. .item-type.active{
  411. background-color: #4F88F7;
  412. border: none;
  413. color: #fff;
  414. }
  415. }
  416. }
  417. .price-text {
  418. font-size: 20upx;
  419. margin-left: 10upx;
  420. }
  421. .price-num {
  422. font-size: 32upx;
  423. color: red;
  424. font-weight: 600;
  425. margin-right: 6rpx;
  426. }
  427. .u-cell {
  428. padding: 10rpx 32rpx;
  429. }
  430. }
  431. .footer {
  432. padding: 20rpx 32rpx;
  433. display: flex;
  434. background-color: #fff;
  435. }
  436. }
  437. </style>