entering.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363
  1. <template>
  2. <view class="container-entering">
  3. <navbar :config="config" backColor="#666666"></navbar>
  4. <view class="form">
  5. <u-form :model="form" ref="formRef" label-width="240">
  6. <u-form-item label="会员手机号:" prop="user_mobile">
  7. <u-input v-model="form.user_mobile" disabled placeholder="请扫描会员码" />
  8. <view class="iconfont3 qrCode" @click="screenQR">&#xe739;</view>
  9. </u-form-item>
  10. <u-form-item label="会员名称:">
  11. <u-input v-model="form.user_name" disabled placeholder="请输入会员名称" />
  12. </u-form-item>
  13. <u-form-item label="消费金额(¥):" prop="sales_money">
  14. <u-input v-model="form.sales_money" placeholder="请输入消费金额" @blur="blurChange" />
  15. </u-form-item>
  16. <u-form-item label="打赏比例(%):" prop="discount_ratio">
  17. <u-input v-model="form.discount_ratio" placeholder="请输入优惠比例" @blur="blurChange" />
  18. </u-form-item>
  19. <u-form-item label="打赏金额:">
  20. <u-input v-model="form.discount_money" disabled placeholder="打赏金额自动计算带入" />
  21. </u-form-item>
  22. <u-form-item label="用户获得贡献值:">
  23. <u-input v-model="form.give_user_commission_able" disabled placeholder="用户获得贡献值自动计算带入" />
  24. </u-form-item>
  25. <u-form-item label="商家获得贡献值:">
  26. <u-input v-model="form.give_shop_commission_able" disabled placeholder="商家获得贡献值自动计算带入" />
  27. </u-form-item>
  28. <u-form-item label="支付方式:" prop="pay_label">
  29. <u-input v-model="form.pay_label" type="select" placeholder="请选择" @click="payPopup = true" />
  30. </u-form-item>
  31. <u-form-item label="订单备注:" label-position="top" class="content-box">
  32. <u-input v-model="form.remark" border maxlength="600" type="textarea" placeholder="请输入" />
  33. </u-form-item>
  34. </u-form>
  35. </view>
  36. <view class="jg"></view>
  37. <view class="user-box" v-if="shop_consume_integral_able != '' || current_integral_able != ''">
  38. <view class="box">
  39. <text class="label">商家打赏积分数:</text>
  40. <text>{{this.shop_consume_integral_able}}</text>
  41. </view>
  42. <view class="box">
  43. <text class="label">可用积分:</text>
  44. <text>{{this.current_integral_able}}</text>
  45. </view>
  46. </view>
  47. <u-select v-model="payPopup" label-name="name" value-name="id" :list="payList" :default-value="[payIndex]"
  48. @confirm="payConfirm"></u-select>
  49. <view class="footer">
  50. <view class="btn" @click="submitEnter">确认上报</view>
  51. </view>
  52. </view>
  53. </template>
  54. <script>
  55. export default {
  56. data() {
  57. return {
  58. config: {
  59. back: true,
  60. title: '订单上报',
  61. color: '#1A1A1A',
  62. backgroundColor: [1, "#fff"],
  63. statusBarFontColor: '#1A1A1A',
  64. leftSlot: true
  65. },
  66. form: {},
  67. rules: {
  68. user_mobile: [{
  69. required: true,
  70. message: '会员手机号不能为空',
  71. trigger: ['change', 'blur'],
  72. }],
  73. sales_money: [{
  74. required: true,
  75. message: '消费金额不能为空',
  76. trigger: ['change', 'blur'],
  77. }, {
  78. validator: (rule, value, callback) => {
  79. if (!this.scanUserInfo.id) {
  80. return callback(new Error('请先扫描会员码'));
  81. }
  82. if (this.$u.test.chinese(value)) {
  83. return callback(new Error('请输入数字类型'));
  84. }
  85. if (!this.$u.test.amount(value)) {
  86. return callback(new Error('最多两位小数'));
  87. }
  88. callback();
  89. },
  90. // message: '最多两位小数',
  91. trigger: ['change', 'blur'],
  92. }],
  93. discount_ratio: [{
  94. required: true,
  95. message: '优惠比例不能为空',
  96. trigger: ['change', 'blur'],
  97. }, {
  98. validator: (rule, value, callback) => {
  99. if (!this.scanUserInfo.id) {
  100. return callback(new Error('请先扫描会员码'));
  101. }
  102. if (!this.form.sales_money) {
  103. return callback(new Error('请先输入消费金额'));
  104. }
  105. if (this.$u.test.chinese(value)) {
  106. return callback(new Error('请输入数字类型'));
  107. }
  108. if (!this.$u.test.range(value, [1, 100])) {
  109. return callback(new Error('请输入1-100的值'));
  110. }
  111. if (!this.$u.test.amount(value)) {
  112. return callback(new Error('最多两位小数'));
  113. }
  114. callback();
  115. },
  116. // message: '请输入1-100的值',
  117. trigger: ['change', 'blur'],
  118. }],
  119. pay_label: [{
  120. required: true,
  121. message: '请选择支付方式',
  122. trigger: ['change', 'blur'],
  123. }],
  124. },
  125. payPopup: false,
  126. payIndex: 0,
  127. payList: [{
  128. code: 'WE_CHAT',
  129. name: '微信',
  130. id: 0
  131. },
  132. {
  133. code: 'ALIPAY',
  134. name: '支付宝',
  135. id: 1
  136. },
  137. {
  138. code: 'MONEY',
  139. name: '现金',
  140. id: 2
  141. },
  142. {
  143. code: 'WE_CHAT_MONEY',
  144. name: '微信+现金',
  145. id: 3
  146. },
  147. {
  148. code: 'ALIPAY_MONEY',
  149. name: '支付宝+现金',
  150. id: 4
  151. },
  152. {
  153. code: 'OTHER',
  154. name: '其他支付',
  155. id: 5
  156. }
  157. ],
  158. current_integral_able: '',
  159. shop_consume_integral_able: '',
  160. enough_shop_consume: false,
  161. scanUserInfo: {}
  162. }
  163. },
  164. onLoad() {
  165. },
  166. onReady() {
  167. this.$refs.formRef.setRules(this.rules);
  168. },
  169. methods: {
  170. getTip() {
  171. if (!this.scanUserInfo.id) {
  172. return '请先扫描会员码'
  173. } else {
  174. return '最多两位小数'
  175. }
  176. },
  177. screenQR() {
  178. uni.scanCode({
  179. scanType: ['qrCode'],
  180. autoDecodeCharset: true,
  181. success: (res) => {
  182. if (res.errMsg == 'scanCode:ok') {
  183. let code = res.result.split('?')[1].split('=')[1]
  184. this.getScanUserInfo(code)
  185. }
  186. }
  187. });
  188. },
  189. payConfirm(e) {
  190. this.payIndex = e[0].value
  191. this.form.pay_mode = e[0].value
  192. this.form.pay_label = e[0].label
  193. },
  194. blurChange(e) {
  195. if (this.form.sales_money && this.form.discount_ratio) {
  196. this.getEnterInfo()
  197. }
  198. },
  199. // 获取会员信息
  200. getScanUserInfo(code) {
  201. this.$http.get('/account/getByCode', {
  202. code: code
  203. }).then(res => {
  204. if (res.code == 200) {
  205. this.scanUserInfo = res.data
  206. this.form.user_mobile = res.data.mobile_desensitized
  207. this.form.user_name = res.data.real_name
  208. this.$forceUpdate()
  209. }
  210. })
  211. },
  212. // 获取上报构单信息
  213. getEnterInfo() {
  214. this.$http.post('/offlineorder/build', {
  215. user_id: this.scanUserInfo.id,
  216. sales_money: this.form.sales_money,
  217. discount_ratio: this.form.discount_ratio
  218. }).then(res => {
  219. if (res.code == 200) {
  220. this.form.discount_money = res.data.discount_money
  221. this.form.give_user_commission_able = res.data.give_user_commission_able
  222. this.form.give_shop_commission_able = res.data.give_shop_commission_able
  223. this.current_integral_able = res.data.current_integral_able
  224. this.shop_consume_integral_able = res.data.shop_consume_integral_able
  225. this.enough_shop_consume = res.data.enough_shop_consume
  226. this.$forceUpdate()
  227. }
  228. })
  229. },
  230. // 确认上报
  231. submitEnter() {
  232. this.$refs.formRef.validate(valid => {
  233. if (valid) {
  234. if (!this.enough_shop_consume) {
  235. return this.$mUtil.toast('积分不足,无法上报')
  236. }
  237. this.$http.post('/offlineorder/create', {
  238. user_id: this.scanUserInfo.id,
  239. sales_money: this.form.sales_money,
  240. discount_ratio: this.form.discount_ratio,
  241. pay_mode: this.form.pay_mode,
  242. remark: this.form.remark
  243. }).then(res => {
  244. if (res.code == 200) {
  245. this.$mUtil.toast('上报成功')
  246. setTimeout(() => {
  247. uni.redirectTo({
  248. url: '/pages/workbench/order/index'
  249. })
  250. }, 1000)
  251. }
  252. })
  253. } else {
  254. console.log('验证失败');
  255. }
  256. })
  257. }
  258. }
  259. }
  260. </script>
  261. <style lang="scss" scoped>
  262. .container-entering {
  263. padding-bottom: 200rpx;
  264. .form {
  265. /deep/ .u-form {
  266. padding: 0 30rpx;
  267. .u-input {
  268. text-align: right !important;
  269. }
  270. .uni-input-placeholder {
  271. text-align: right;
  272. }
  273. // .u-input__right-icon__item {
  274. // display: flex;
  275. // align-items: center;
  276. // }
  277. // .uicon-arrow-down-fill::before {
  278. // width: 32rpx;
  279. // height: 32rpx;
  280. // content: '';
  281. // background: url('@/static/personal/select-icon.png') no-repeat;
  282. // background-size: 100% 100%;
  283. // }
  284. }
  285. .qrCode {
  286. font-size: 50rpx;
  287. }
  288. .content-box {
  289. .u-input {
  290. text-align: left !important;
  291. }
  292. .uni-input-placeholder {
  293. text-align: left;
  294. }
  295. }
  296. }
  297. .jg {
  298. height: 10rpx;
  299. background: #f5f5f5;
  300. }
  301. .user-box {
  302. padding: 30rpx;
  303. }
  304. .box {
  305. font-size: 28rpx;
  306. font-family: PingFang SC, PingFang SC-Regular;
  307. font-weight: 400;
  308. text-align: left;
  309. color: #808080;
  310. margin-bottom: 10rpx;
  311. .label {
  312. color: #1A1A1A;
  313. }
  314. }
  315. .footer {
  316. width: 100%;
  317. padding: 30rpx 60rpx;
  318. position: fixed;
  319. bottom: 0;
  320. display: flex;
  321. align-items: center;
  322. justify-content: space-between;
  323. background-color: #fff;
  324. .btn {
  325. width: 100%;
  326. color: #fff;
  327. text-align: center;
  328. line-height: 85rpx;
  329. border: 1rpx solid #3775F6;
  330. border-radius: 44rpx;
  331. background-color: #FA6138;
  332. font-size: 28rpx;
  333. font-family: PingFang SC, PingFang SC-Regular;
  334. font-weight: 400;
  335. text-align: center;
  336. }
  337. .online-btn {
  338. color: #FA6138;
  339. border: 1rpx solid #3775F6;
  340. background-color: #e7eefc;
  341. }
  342. }
  343. }
  344. </style>