account.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213
  1. <template>
  2. <view class="main main-bg">
  3. <u-form :model="form" ref="uForm" :rules="rules">
  4. <u-form-item
  5. label="商品金额"
  6. label-width="180"
  7. :label-position="labelPosition"
  8. prop="orderPriceOld">
  9. <u-input
  10. v-model="form.orderPriceOld"
  11. placeholder-style="color: #2E4F1C;"
  12. placeholder="请输入商品金额" />
  13. </u-form-item>
  14. <u-form-item
  15. label="商品折扣"
  16. label-width="180"
  17. :label-position="labelPosition"
  18. prop="shopsTel">
  19. <view class="form-item">
  20. <u-input
  21. v-model="form.shopsTel"
  22. placeholder-style="color: #2E4F1C;"
  23. placeholder="请输入商品折扣" />
  24. </view>
  25. </u-form-item>
  26. </u-form-item>
  27. <u-upload
  28. width="160"
  29. height="160"
  30. :action="action"
  31. max-count="3"
  32. @on-success="onSuccess">
  33. </u-upload>
  34. </u-form>
  35. <view @click="submit" class="form-submit">结算</view>
  36. <u-toast ref="uToast" />
  37. </view>
  38. </template>
  39. <script>
  40. import http from '@/common/http.js'
  41. import server from "@/api/index";
  42. export default {
  43. data() {
  44. return {
  45. action: http.webUrl+`/wx/common/upload`,
  46. picUrlList: [],
  47. labelPosition: 'left',
  48. form: {
  49. orderPriceOld: null,
  50. shopsTel: 1.00,
  51. },
  52. rules: {
  53. orderPriceOld: [
  54. {
  55. required: true,
  56. message: '请输入商品金额!',
  57. trigger: ['change','blur'],
  58. },
  59. {
  60. validator: (rule, value, callback) => {
  61. return this.$u.test.amount(value);
  62. },
  63. message: '商品金额必须是数字!',
  64. trigger: ['change','blur'],
  65. }
  66. ],
  67. shopsTel: [
  68. {
  69. validator: (rule, value, callback) => {
  70. return this.$u.test.range(value, [0, 1]);
  71. },
  72. message: '商品折扣必须是0-1之间!',
  73. trigger: ['change','blur'],
  74. }
  75. ],
  76. },
  77. userInfo:{},
  78. veteransId: 0,
  79. remark: '',
  80. veteransName: '',
  81. picUrlList: []
  82. }
  83. },
  84. onLoad(e) {
  85. console.log(e)
  86. if(e.veteransId){
  87. this.veteransId = parseInt(e.veteransId);
  88. this.remark = e.remark;
  89. this.veteransName = e.veteransName
  90. }
  91. this.userInfo = uni.getStorageSync('userInfo');
  92. },
  93. onReady() {
  94. this.$refs.uForm.setRules(this.rules);
  95. },
  96. methods:{
  97. onSuccess(data, index, lists, name){
  98. this.picUrlList = [];
  99. lists.forEach(item =>{
  100. this.picUrlList.push(item.response.fileName)
  101. })
  102. },
  103. submit() {
  104. console.log(this.form.shopsTel.toString().substr(0,1))
  105. let that= this;
  106. this.$refs.uForm.validate(valid => {
  107. if (valid) {
  108. if(this.form.shopsTel.toString().substr(0,1) === '.'){
  109. this.form.shopsTel = '0'+ this.form.shopsTel
  110. }
  111. let money = this.form.shopsTel*this.form.orderPriceOld;
  112. uni.showModal({
  113. title: '提示',
  114. content: '确认结算吗?',
  115. success: function (res) {
  116. if (res.confirm) {
  117. let params = {
  118. shopsId: that.userInfo.nickName,
  119. goodsName: that.userInfo.userName,
  120. veteransName: that.veteransName,
  121. veteransId: that.veteransId,
  122. remark: that.remark,
  123. orderPriceOld: that.form.orderPriceOld,
  124. orderPriceVip: money,
  125. picUrlList: that.picUrlList,
  126. detailedlist: []
  127. }
  128. server.addOrderInfo(params).then(res =>{
  129. that.$refs.uToast.show({
  130. title: '操作成功!',
  131. type: 'default',
  132. })
  133. setTimeout(function() {
  134. uni.switchTab({
  135. url: '/pages/index/index'
  136. })
  137. }, 2000);
  138. })
  139. } else if (res.cancel) {
  140. console.log('用户点击取消');
  141. }
  142. }
  143. });
  144. }
  145. })
  146. console.log('this.form', this.form)
  147. },
  148. }
  149. }
  150. </script>
  151. <style lang="scss" scoped>
  152. /deep/ .u-list-item{
  153. margin: 0rpx 0rpx 0rpx 16rpx!important;
  154. }
  155. /deep/ .u-icon__icon{
  156. position: relative;
  157. color: #2E4F1C!important;
  158. }
  159. /deep/ .u-form-item__message{
  160. padding-right: 0rpx!important;
  161. text-align: right;
  162. }
  163. /deep/ .u-input__input{
  164. color: #2E4F1C!important;
  165. font-size: 28rpx;
  166. font-family: PingFangSC-Regular, PingFang SC;
  167. font-weight: 400;
  168. text-align: right;
  169. }
  170. /deep/ .u-border, .u-border-bottom, .u-border-left, .u-border-right, .u-border-top, .u-border-top-bottom{
  171. }
  172. /deep/ .u-form-item{
  173. display: -webkit-box;
  174. display: -webkit-flex;
  175. display: flex;
  176. -webkit-box-orient: horizontal;
  177. -webkit-box-direction: normal;
  178. -webkit-flex-direction: row;
  179. flex-direction: row;
  180. box-sizing: border-box;
  181. line-height: 96rpx;
  182. -webkit-flex-direction: column;
  183. flex-direction: column;
  184. background: rgba(46, 79, 28, 0.13);
  185. border-radius: 24rpx;
  186. margin-bottom: 40rpx;
  187. padding-left: 30rpx!important;
  188. padding-right: 30rpx!important;
  189. }
  190. .main{
  191. width: 100%;
  192. height: auto;
  193. min-height: 100vh;
  194. padding: 60rpx 30rpx 30rpx;
  195. .form-submit{
  196. margin: 60rpx auto;
  197. width: 570rpx;
  198. height: 96rpx;
  199. line-height: 96rpx;
  200. background: #2E4F1C;
  201. border-radius: 49rpx;
  202. font-size: 36rpx;
  203. text-align: center;
  204. font-family: PingFangSC-Medium, PingFang SC;
  205. font-weight: 500;
  206. color: #fff;
  207. }
  208. }
  209. </style>