index.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  1. <template>
  2. <view>
  3. <view class="container-body">
  4. <view class="title">发票详情</view>
  5. <view class="formbox">
  6. <u-form labelPosition="left" labelWidth='80' :model="formdata" :rules="rules" ref="uForm"
  7. errorType="toast">
  8. <u-form-item label="抬头类型" prop="billType">
  9. <u-radio-group v-model="formdata.billType" placement="row" size="30rpx" @change="billTypeChange">
  10. <u-radio activeColor="#FF5C03" label="企业单位" :name="0"></u-radio>
  11. <u-radio style="margin-left: 40rpx;" activeColor="#FF5C03" label="个人/非企业单位"
  12. :name="1"></u-radio>
  13. </u-radio-group>
  14. </u-form-item>
  15. <u-form-item label="发票抬头" prop="saleName">
  16. <u-input v-model="formdata.saleName" border="none" :clearable="true"
  17. placeholder="填写发票抬头"></u-input>
  18. </u-form-item>
  19. <u-form-item label="税号" prop="saleNo" v-if="formdata.billType != 1">
  20. <u-input v-model="formdata.saleNo" border="none" :clearable="true" placeholder="填写税号"></u-input>
  21. </u-form-item>
  22. <!-- <u-form-item label="更多内容">
  23. <view class="more" @click="handleMore">
  24. <text style="margin-right: 10rpx;">共5项,已填写0项</text>
  25. <u-icon name="arrow-right" color="#999999"></u-icon>
  26. </view>
  27. </u-form-item> -->
  28. <u-form-item label="总金额" prop="amount">
  29. <view style="width: 100px;">
  30. <u-input v-model="formdata.amount" border="none" :clearable="true" placeholder="填写总金额"
  31. color="#FF5C03"></u-input>
  32. </view>
  33. <view slot="suffix" class="title" style="padding: 0;">元</view>
  34. </u-form-item>
  35. <u-form-item label="备注药品信息" prop="memo" labelWidth='110'>
  36. <u-radio-group v-model="formdata.memo" placement="row" size="30rpx">
  37. <u-radio activeColor="#FF5C03" label="是" :name="1"></u-radio>
  38. <u-radio style="margin-left: 40rpx;" activeColor="#FF5C03" label="否" :name="0"></u-radio>
  39. </u-radio-group>
  40. </u-form-item>
  41. </u-form>
  42. </view>
  43. <view class="title" style="color: red;">温馨提示</view>
  44. <view class="title" style="padding: 0 24rpx;">1.请您仔细核对您填写的发票信息,<text
  45. style="color: #3182bd;">发票只能开一次</text>,不允许修改重开!</view>
  46. <view class="title" style="padding: 0 24rpx;">2.互联网医院仅支持普票,不支持开具专票!</view>
  47. <view class="title" style="padding: 0 24rpx;">3.如开票后申请退款成功,发票将自动冲红作废,不能进行报销。</view>
  48. </view>
  49. <view class="footerbox x-ac">
  50. <view class="footerbox-btn x-ac" @click="submit">提交</view>
  51. </view>
  52. <uni-popup ref="popup" type="center" :is-mask-click="false">
  53. <view class="popup-content">
  54. <image class="es-w-50 es-h-50" style="position: absolute;right:24rpx;top:24rpx"
  55. @tap="closepop" src="/static/images/close40.png"></image>
  56. <view class="popup-title">确认发票信息</view>
  57. <view class="x-start">
  58. <view class="label">抬头类型:</view><text>{{formdata.billType==1 ? "个人/非企业单位" : "企业单位"}}</text>
  59. </view>
  60. <view class="x-f es-mb-20 es-mt-20">
  61. <view class="label">发票抬头:</view><text>{{formdata.saleName}}</text>
  62. </view>
  63. <view class="x-f" v-if="formdata.billType != 1">
  64. <view class="label">发票税号:</view><text>{{formdata.saleNo}}</text>
  65. </view>
  66. <button class="submitbtn x-ac" @click="confirm" :disabled="btnLoading">确认提交</button>
  67. </view>
  68. </uni-popup>
  69. </view>
  70. </template>
  71. <script>
  72. import {bill} from "@/api/store.js"
  73. import {getMyStoreOrderById,cancelOrder,finishOrder} from '@/api/storeOrder'
  74. export default {
  75. data() {
  76. const checkIsNum = (rule, value, callback) => {
  77. const reg = /^\d+(\.\d{1,2})?$/
  78. if (!reg.test(value)) {
  79. callback(new Error("请输入正确的金额"));
  80. } else {
  81. callback();
  82. }
  83. };
  84. return {
  85. btnLoading: false,
  86. userInfo: {},
  87. payPrice: 0,
  88. orderId: "",
  89. show: false,
  90. title: '确认发票信息',
  91. formdata: {
  92. billType: 0,
  93. saleName: "",
  94. saleNo: "",
  95. amount: "",
  96. memo: 0,
  97. },
  98. rules: {
  99. saleName: [{
  100. required: true,
  101. message: '请输入发票抬头',
  102. // 可以单个或者同时写两个触发验证方式
  103. trigger: ['change', 'blur'],
  104. }],
  105. saleNo: [{
  106. required: true,
  107. message: '请输入税号',
  108. // 可以单个或者同时写两个触发验证方式
  109. trigger: ['change', 'blur'],
  110. }],
  111. amount: [{
  112. required: true,
  113. message: '请输入总金额',
  114. // 可以单个或者同时写两个触发验证方式
  115. trigger: ['change', 'blur'],
  116. },
  117. {
  118. validator: checkIsNum,
  119. trigger: ["blur", "change"]
  120. },
  121. ],
  122. }
  123. }
  124. },
  125. onLoad(option) {
  126. this.userInfo = uni.getStorageSync("userInfo") ? JSON.parse(uni.getStorageSync("userInfo")) : {}
  127. this.orderId = option.orderId
  128. this.getMyStoreOrderById()
  129. },
  130. onReady() {
  131. //onReady 为uni-app支持的生命周期之一
  132. this.$refs.uForm.setRules(this.rules)
  133. },
  134. methods: {
  135. handleMore() {
  136. uni.navigateTo({
  137. url: '/pages/store/invoiceOther'
  138. })
  139. },
  140. getMyStoreOrderById(){
  141. var data={orderId:this.orderId};
  142. getMyStoreOrderById(data).then(res => {
  143. if(res.code==200){
  144. this.payPrice=Number(res.order.payPrice || 0) - Number(res.order.billPrice || 0);
  145. this.formdata.amount = String(this.payPrice || 0)
  146. this.$forceUpdate()
  147. }else{
  148. uni.showToast({
  149. icon:'none',
  150. title: "请求失败",
  151. });
  152. }
  153. });
  154. },
  155. billTypeChange() {
  156. if(this.formdata.billType == 1) {
  157. this.rules.saleNo[0].required = false
  158. this.$refs.uForm.setRules(this.rules)
  159. } else {
  160. this.rules.saleNo[0].required = true
  161. this.$refs.uForm.setRules(this.rules)
  162. }
  163. },
  164. submit() {
  165. this.$refs.uForm.validate().then(res => {
  166. if(Number(this.formdata.amount || 0) > this.payPrice) {
  167. uni.showToast({
  168. title: "总金额不能大于订单应付金额",
  169. icon: "none"
  170. })
  171. return
  172. }
  173. this.$refs.popup.open()
  174. })
  175. },
  176. closepop() {
  177. this.$refs.popup.close()
  178. },
  179. confirm() {
  180. const param = {
  181. orderId: this.orderId,
  182. billType: this.formdata.billType,
  183. saleName: this.formdata.saleName,
  184. saleNo: this.formdata.billType == 1 ? '' : this.formdata.saleNo,
  185. amount: this.formdata.amount,
  186. memo: this.formdata.memo == 1 ? true : false,
  187. userId: this.userInfo.userId
  188. }
  189. this.btnLoading = true
  190. bill(param).then(res=>{
  191. this.btnLoading = false
  192. this.$refs.popup.close()
  193. if(res.code == 200) {
  194. uni.showToast({
  195. title: "提交成功,请10分钟后在开票历史查看结果",
  196. icon: "none",
  197. duration: 3000
  198. })
  199. uni.$emit("refreshStoreOrder")
  200. uni.$emit("refreshOrderDetail")
  201. setTimeout(()=>{
  202. this.$navBack()
  203. },3000)
  204. } else {
  205. uni.showToast({
  206. title: res.msg,
  207. icon: "none",
  208. duration: 3000
  209. })
  210. }
  211. }).catch(()=>{
  212. this.btnLoading = false
  213. this.$refs.popup.close()
  214. })
  215. }
  216. }
  217. }
  218. </script>
  219. <style lang="scss" scoped>
  220. .title {
  221. padding: 24rpx;
  222. font-family: PingFang SC, PingFang SC;
  223. font-weight: 400;
  224. font-size: 24rpx;
  225. color: #999999;
  226. }
  227. .formbox {
  228. padding: 20rpx;
  229. background-color: #fff;
  230. }
  231. .more {
  232. width: 100%;
  233. display: flex;
  234. align-items: center;
  235. justify-content: flex-end;
  236. font-family: PingFang SC, PingFang SC;
  237. font-weight: 400;
  238. font-size: 24rpx;
  239. color: #999999;
  240. }
  241. .container-body {
  242. padding-bottom: calc(var(--window-bottom) + 154rpx);
  243. }
  244. .popup-content {
  245. background-color: #fff;
  246. border-radius: 20rpx;
  247. width: 630rpx;
  248. padding: 24rpx 36rpx;
  249. box-sizing: border-box;
  250. font-family: PingFang SC, PingFang SC;
  251. font-weight: 400;
  252. word-break: break-all;
  253. font-size: 28rpx;
  254. color: #757575;
  255. .label {
  256. flex-shrink: 0;
  257. color: #303133;
  258. }
  259. .popup-title {
  260. font-weight: 500;
  261. font-size: 34rpx;
  262. color: #333333;
  263. text-align: center;
  264. padding: 24rpx 24rpx 36rpx 24rpx;
  265. }
  266. .submitbtn {
  267. margin-top: 70rpx;
  268. width: 100%;
  269. min-height: 84rpx;
  270. background: #FF5C03;
  271. border-radius: 42rpx 42rpx 42rpx 42rpx;
  272. font-weight: 500;
  273. font-size: 32rpx;
  274. color: #FFFFFF;
  275. }
  276. }
  277. .footerbox {
  278. width: 100%;
  279. padding: 20rpx 24rpx;
  280. padding-bottom: calc(var(--window-bottom) + 20rpx);
  281. background-color: #fff;
  282. position: fixed;
  283. bottom: 0;
  284. left: 0;
  285. z-index: 99;
  286. &-btn {
  287. width: 702rpx;
  288. height: 96rpx;
  289. background: #FF5C03;
  290. border-radius: 96rpx;
  291. font-family: PingFang SC, PingFang SC;
  292. font-weight: 600;
  293. font-size: 36rpx;
  294. color: #FFFFFF;
  295. }
  296. }
  297. </style>