paymentWay.vue 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. <template>
  2. <view>
  3. <z-text arrow v-model="paywaycontent" :placeholder="placeholder" @click="visible=true"></z-text>
  4. <z-slide-card title="收费方式" :visible.sync="visible" @beforeClose="beforeClose" rightBtnText="确定" @rightClick="submit"
  5. ref="slide">
  6. <z-tabs class="shadow-2" v-if="showtab" :tabs="tabList" v-model="stateTab" @change="changeTabs" bgcolor="white"
  7. textselectedcolor="#333333"></z-tabs>
  8. <z-card class="mt-40" v-show="stateTab==0">
  9. <z-cell label="每人价格" height="100rpx">
  10. <z-input type="number" v-model="perPeoplePrice" placeholder="¥" :max="100000" :min="0" @change="changeperPeoplePrice"></z-input>
  11. </z-cell>
  12. <z-cell label="预定人数" height="100rpx" hideline>
  13. <z-input type="digit" v-model="peopleNum" placeholder="填写预定人数" :max="1000" :min="0" :decimal="1" :step="0.5" @change="changepeopleNum"></z-input>
  14. </z-cell>
  15. </z-card>
  16. <z-card class="mt-40" v-show="stateTab==1">
  17. <z-cell label="每桌价格" height="100rpx">
  18. <z-input type="number" v-model="perTablePrice" placeholder="¥" :max="100000" :min="0"></z-input>
  19. </z-cell>
  20. <z-cell label="预定桌数" height="100rpx" hideline>
  21. <z-input type="digit" v-model="tableNum" placeholder="填写预定桌数" :max="1000" :min="0" :decimal="1" :step="0.5"></z-input>
  22. </z-cell>
  23. </z-card>
  24. <z-card class="mt-40" v-show="stateTab==2">
  25. <z-cell label="场地费" height="100rpx">
  26. <z-input type="number" v-model="areaMoney" placeholder="¥" :max="100000" :min="0"></z-input>
  27. </z-cell>
  28. <z-cell label="加桌" height="100rpx">
  29. <switch :checked="addTables" @change="changeaddTables" />
  30. </z-cell>
  31. <z-cell label="加人" height="100rpx" :hideline="!addTables&&!addPeoples">
  32. <switch :checked="addPeoples" @change="changeaddPeoples" />
  33. </z-cell>
  34. <template v-if="addTables">
  35. <z-cell label="每桌价格" height="100rpx">
  36. <z-input type="number" v-model="perTablePrice" placeholder="¥" :max="100000" :min="0"></z-input>
  37. </z-cell>
  38. <z-cell label="预定桌数" height="100rpx" >
  39. <z-input type="digit" v-model="tableNum" placeholder="填写预定桌数" :max="1000" :min="0" :decimal="1" :step="0.5"></z-input>
  40. </z-cell>
  41. </template>
  42. <template v-if="addPeoples">
  43. <z-cell label="每人价格" height="100rpx">
  44. <z-input type="number" v-model="perPeoplePrice" placeholder="¥" :max="100000" :min="0"></z-input>
  45. </z-cell>
  46. <z-cell label="预定人数" height="100rpx" hideline>
  47. <z-input type="digit" v-model="peopleNum" placeholder="填写预定人数" :max="1000" :min="0" :decimal="1" :step="0.5"></z-input>
  48. </z-cell>
  49. </template>
  50. </z-card>
  51. <z-card class="paytotal mt-40 flex-n fac fje">
  52. <view class="plr-20">合计:{{totalMoney}}</view>
  53. </z-card>
  54. <z-card class="mt-40" v-show="addTables||stateTab==1">
  55. <z-cell label="备用桌数" hideline>
  56. <z-input type="number" v-model="bdesks" placeholder="填写备用桌数" :max="1000"></z-input>
  57. </z-cell>
  58. </z-card>
  59. </z-slide-card>
  60. </view>
  61. </template>
  62. <script>
  63. export default {
  64. props: {
  65. multiple: Boolean,
  66. value: String | Array,
  67. placeholder: String,
  68. showtab: {
  69. type: Boolean,
  70. default: true
  71. },
  72. payTypes: Array
  73. },
  74. model: {
  75. prop: 'value',
  76. event:'input'
  77. },
  78. data() {
  79. return {
  80. visible: false,
  81. stateTab: 0,
  82. paywayList:[],
  83. tabList:[],
  84. addTables: false,
  85. addPeoples: false,
  86. paywaycontent: '',
  87. perTablePrice: '',
  88. tableNum: '',
  89. perPeoplePrice: '',
  90. peopleNum: '',
  91. areaMoney: '',
  92. bdesks: '',
  93. oldpayTypes: [],
  94. oldstateTab: '01'
  95. }
  96. },
  97. onBackPress() {
  98. if(this.visible) {
  99. this.visible = false;
  100. return true;
  101. }
  102. },
  103. mounted() {
  104. this.getPaywayList()
  105. },
  106. computed: {
  107. totalMoney() {
  108. if (this.stateTab == 0) {
  109. return Number(this.perPeoplePrice || 0) * Number(this.peopleNum || 0);
  110. }
  111. if (this.stateTab == 1) {
  112. return Number(this.perTablePrice || 0) * Number(this.tableNum || 0);
  113. }
  114. if (this.stateTab == 2) {
  115. var money = 0;
  116. if (this.addPeoples) {
  117. money += Number(this.perPeoplePrice || 0) * Number(this.peopleNum || 0);
  118. }
  119. if (this.addTables) {
  120. money += Number(this.perTablePrice || 0) * Number(this.tableNum || 0);
  121. }
  122. money += Number(this.areaMoney || 0);
  123. return money;
  124. }
  125. }
  126. },
  127. watch: {
  128. value(newval, oldval) {
  129. this.oldstateTab = newval||'01';
  130. this.getState(newval);
  131. },
  132. payTypes(newval, oldval) {
  133. this.oldpayTypes = newval;
  134. this.getData(newval);
  135. }
  136. },
  137. methods: {
  138. changeperPeoplePrice(data){
  139. this.perPeoplePrice=data;
  140. },
  141. changepeopleNum(data){
  142. this.peopleNum=data;
  143. },
  144. getPaywayList(){
  145. this.$axios.post('app/dic/payTypeCode', {
  146. "parentId": "1001",
  147. "dicType": " pay_type_code "
  148. }).then(res => {
  149. console.log('收费方式', res.data)
  150. this.paywayList = res.data.list;
  151. for(var i in this.paywayList){
  152. this.tabList.push(this.paywayList[i].dicName);
  153. }
  154. }).catch(err => {
  155. console.log(err.msg);
  156. })
  157. },
  158. getState(state) {
  159. if (state == '01') {
  160. this.stateTab = 0;
  161. } else if (state == '02') {
  162. this.stateTab = 1;
  163. } else {
  164. this.stateTab = 2;
  165. }
  166. },
  167. getData(payTypes) {
  168. for (var i in payTypes) {
  169. if (payTypes[i].payTypeCode == '01') {
  170. if (this.stateTab == 2) {
  171. this.addPeoples = true;
  172. }
  173. this.perPeoplePrice = payTypes[i].onePrice;
  174. this.peopleNum = payTypes[i].orderCount;
  175. }
  176. if (payTypes[i].payTypeCode == '02') {
  177. if (this.stateTab == 2) {
  178. this.addTables = true;
  179. }
  180. this.bdesks = payTypes[i].bakOrderCount;
  181. this.perTablePrice = payTypes[i].onePrice;
  182. this.tableNum = payTypes[i].orderCount;
  183. }
  184. if (payTypes[i].payTypeCode == '03') {
  185. this.areaMoney = payTypes[i].housePrice;
  186. }
  187. }
  188. this.getContent();
  189. },
  190. getContent() {
  191. if (this.stateTab == 0) {
  192. this.paywaycontent = (this.perPeoplePrice||0) + '元 * ' + (this.peopleNum||0) + '人 = ' + this.totalMoney + '元';
  193. } else if (this.stateTab == 1) {
  194. this.paywaycontent = (this.perTablePrice||0) + '元 * ' + (this.tableNum||0) + '桌 = ' + this.totalMoney + '元' + (this.bdesks ?
  195. ('(备' + this.bdesks + ')') : '');
  196. } else {
  197. var content = '';
  198. content += (this.areaMoney||0) + '元/场,';
  199. if ((this.addTables && this.tableNum) || (this.addPeoples && this.peopleNum)) {
  200. content += '另加';
  201. if (this.tableNum) {
  202. content += (this.tableNum||0) + '桌' + (this.bdesks ? ('(备' + this.bdesks + '桌)') : '') + ',';
  203. }
  204. if (this.peopleNum) {
  205. content += (this.peopleNum||0) + '人,'
  206. }
  207. }
  208. if (content.length > 0)
  209. content = content.substring(0, content.length - 1);
  210. this.paywaycontent = content;
  211. }
  212. },
  213. changeaddTables(e) {
  214. this.addTables = e.detail.value;
  215. },
  216. changeaddPeoples(e) {
  217. this.addPeoples = e.detail.value;
  218. },
  219. changeTabs() {
  220. this.addTables = false;
  221. this.addPeoples = false;
  222. this.perTablePrice = '';
  223. this.tableNum = '';
  224. this.perPeoplePrice = '';
  225. this.peopleNum = '';
  226. this.areaMoney = '';
  227. this.bdesks = '';
  228. },
  229. beforeClose() {
  230. this.getState(this.oldstateTab);
  231. this.getData(this.oldpayTypes);
  232. },
  233. submit() {
  234. // this.visible=false;
  235. var payTypes = [];
  236. if (this.stateTab == 0) {
  237. if (this.perPeoplePrice == '') {
  238. return uni.showToast({
  239. title: '请输入每人价格',
  240. icon: 'none'
  241. });
  242. }
  243. if (this.peopleNum == '') {
  244. return uni.showToast({
  245. title: '请输入预定人数',
  246. icon: 'none'
  247. });
  248. }
  249. payTypes.push({
  250. onePrice: this.perPeoplePrice,
  251. payType: '01',
  252. orderCount: this.peopleNum,
  253. payTypeCode: '01',
  254. });
  255. }
  256. if (this.stateTab == 1) {
  257. if (this.perTablePrice == '') {
  258. return uni.showToast({
  259. title: '请输入每桌价格',
  260. icon: 'none'
  261. });
  262. }
  263. if (this.tableNum == '') {
  264. return uni.showToast({
  265. title: '请输入预定桌数',
  266. icon: 'none'
  267. });
  268. }
  269. payTypes.push({
  270. onePrice: this.perTablePrice,
  271. payType: '02',
  272. payTypeCode: '02',
  273. orderCount: this.tableNum,
  274. bakOrderCount: this.bdesks
  275. });
  276. }
  277. if (this.stateTab == 2) {
  278. if (this.perTablePrice == '' && this.addTables) {
  279. return uni.showToast({
  280. title: '请输入每桌价格',
  281. icon: 'none'
  282. });
  283. }
  284. if (this.tableNum == '' && this.addTables) {
  285. return uni.showToast({
  286. title: '请输入预定桌数',
  287. icon: 'none'
  288. });
  289. }
  290. if (this.perPeoplePrice == '' && this.addPeoples) {
  291. return uni.showToast({
  292. title: '请输入每人价格',
  293. icon: 'none'
  294. });
  295. }
  296. if (this.peopleNum == '' && this.addPeoples) {
  297. return uni.showToast({
  298. title: '请输入预定人数',
  299. icon: 'none'
  300. });
  301. }
  302. if (this.addPeoples) {
  303. payTypes.push({
  304. onePrice: this.perPeoplePrice,
  305. payType: '01',
  306. orderCount: this.peopleNum,
  307. payTypeCode: '01',
  308. });
  309. }
  310. if (this.addTables) {
  311. payTypes.push({
  312. onePrice: this.perTablePrice,
  313. payType: '02',
  314. payTypeCode: '02',
  315. orderCount: this.tableNum,
  316. bakOrderCount: this.bdesks
  317. });
  318. }
  319. payTypes.push({
  320. housePrice: this.areaMoney,
  321. payType: '03',
  322. payTypeCode: '03'
  323. });
  324. }
  325. this.getContent();
  326. this.$emit('payTypes', payTypes)
  327. this.$emit('input',this.paywayList[this.stateTab].dicCode);
  328. this.$refs.slide.close();
  329. this.$emit('getMainPayTypeText',this.tabList[this.stateTab]);
  330. }
  331. }
  332. }
  333. </script>
  334. <style lang="scss" scoped>
  335. .paytotal {
  336. color: #999999;
  337. line-height: 86rpx;
  338. font-size: 32rpx;
  339. }
  340. </style>