index.vue 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404
  1. <template>
  2. <view class="invoice">
  3. <nav-bar title="发票申请"></nav-bar>
  4. <view class="invoice__tabs">
  5. <u-tabs :list="list" sticky :current="current" @change="change" active-color="#007AFF"></u-tabs>
  6. </view>
  7. <view class="invoice__content">
  8. <view class="open" v-if="current == 0">
  9. <view class="form">
  10. <u-form :model="form" ref="uForm">
  11. <u-form-item label="发票类型" label-width="150" required prop="type" >
  12. <u-radio-group v-model="form.type" @change="formTypeChange">
  13. <u-radio v-for="(item, index) in typeList" :key="index" :name="item.value">
  14. {{ item.name }}
  15. </u-radio>
  16. </u-radio-group>
  17. </u-form-item>
  18. <!-- 增值税发票 -->
  19. <template v-if="form.type == 2">
  20. <u-form-item label="申请主体" label-width="150" required prop="subject">
  21. <u-radio-group v-model="form.subject">
  22. <u-radio :key="index" name="2">
  23. 企业
  24. </u-radio>
  25. </u-radio-group>
  26. </u-form-item>
  27. <u-form-item label="发票抬头" label-width="150" required prop="invoiceTitle" >
  28. <u-input placeholder="请输入发票抬头" v-model="form.invoiceTitle" />
  29. </u-form-item>
  30. <u-form-item label="纳税登记号" label-width="150" required prop="taxRegistryNumber" >
  31. <u-input placeholder="请输入纳税登记号" v-model="form.taxRegistryNumber" />
  32. </u-form-item>
  33. <u-form-item label="单位地址" label-width="150" required prop="companyAddress" >
  34. <u-input placeholder="请输入单位地址" v-model="form.companyAddress" />
  35. </u-form-item>
  36. <u-form-item label="电话号码" label-width="150" required prop="phone" >
  37. <u-input placeholder="请输入电话号码" type="number" v-model="form.phone" />
  38. </u-form-item>
  39. <u-form-item label="开户银行" label-width="150" required prop="bankName" >
  40. <u-input placeholder="请输入开户银行" v-model="form.bankName" />
  41. </u-form-item>
  42. <u-form-item label="银行账号" label-width="150" required prop="bankAccount" >
  43. <u-input placeholder="请输入银行账号" type="number" v-model="form.bankAccount" />
  44. </u-form-item>
  45. <u-form-item label="收件地址" label-width="150" required prop="receivingAddress" >
  46. <u-input placeholder="请输入收件地址" v-model="form.receivingAddress" />
  47. </u-form-item>
  48. <u-form-item label="收件人" label-width="150" required prop="receivingName" >
  49. <u-input placeholder="请输入收件人" v-model="form.receivingName" />
  50. </u-form-item>
  51. <u-form-item label="收件手机" label-width="150" required prop="receivingTel" >
  52. <u-input placeholder="请输入收件手机" v-model="form.receivingTel" />
  53. </u-form-item>
  54. </template>
  55. <!-- 增值税发票 -->
  56. <!-- 普通发票 -->
  57. <template v-else>
  58. <u-form-item label="申请主体" label-width="150" required prop="subject">
  59. <u-radio-group v-model="form.subject">
  60. <u-radio v-for="(item, index) in mainList" :key="index" :name="item.value">
  61. {{ item.name }}
  62. </u-radio>
  63. </u-radio-group>
  64. </u-form-item>
  65. <u-form-item label="发票抬头" label-width="150" required prop="invoiceTitle" >
  66. <u-input placeholder="请输入发票抬头" v-model="form.invoiceTitle" />
  67. </u-form-item>
  68. <u-form-item v-if="form.subject == '2'" label="纳税登记号" label-width="150" required prop="taxRegistryNumber" >
  69. <u-input placeholder="请输入纳税登记号" v-model="form.taxRegistryNumber" />
  70. </u-form-item>
  71. </template>
  72. <!-- 普通发票 -->
  73. <u-form-item label="选择订单" label-width="150" required prop="orderGoodsIds" right-icon="arrow-right" ref="orderGoodsIds">
  74. <view class="form-item" @click="selectOrderModal = true">
  75. <u-input placeholder="请点击选择订单" disabled @click="selectOrderModal = true" />
  76. </view>
  77. </u-form-item>
  78. <view>
  79. <view class="check-order" v-for="(item,index) in orderList" :key="index" v-if="item.disabled">
  80. <view class="close" @click="deleteOrder(index)">
  81. <u-icon name="close-circle-fill" color="#FF2D55" size="40"></u-icon>
  82. </view>
  83. <view class="title">商品名称:{{item.goodsName}}</view>
  84. <view class="number">订单编号:{{item.orderSn}}</view>
  85. <view class="price">价格:¥ {{item.goodsPrice}}</view>
  86. </view>
  87. </view>
  88. </u-form>
  89. </view>
  90. <view class="order-text">
  91. <view class="order-text__label">本次申请开票金额:</view>
  92. <view class="order-text__price">¥ {{toFixed(invoicePirce)}}</view>
  93. </view>
  94. <view class="submit" @click="formSubmit">
  95. 提交申请
  96. </view>
  97. </view>
  98. <view class="record" v-if="current == 1">
  99. <view class="nodata" v-if="!recordList.length">
  100. 您暂无相关发票记录哦~
  101. </view>
  102. <view class="record__list">
  103. <view class="record-item" @click="showDetailModal(record);" v-for="(record,index) in recordList" :key="index">
  104. <view class="item__time">{{$method.timestampToTime(record.applyTime,false,false)}}</view>
  105. <view class="item__content">
  106. <view class="top">
  107. <view class="state" :class="{wait:record.periodStatus == 1,refuse:record.periodStatus == 2,agree:record.periodStatus == 3}">
  108. <text v-if="record.periodStatus == 1">待审核</text>
  109. <text v-if="record.periodStatus == 2">驳回</text>
  110. <text v-if="record.periodStatus == 3">通过</text>
  111. <u-icon class="arrow" name="arrow-right" color="#ffffff" size="28"></u-icon>
  112. </view>
  113. </view>
  114. <view class="bottom">
  115. <view class="flex">
  116. <view class="text">发票类型</view>
  117. <view class="flex__auto">
  118. <text v-if="record.type == 1">普通发票</text>
  119. <text v-if="record.type == 2">增值税专用发票</text>
  120. </view>
  121. </view>
  122. <view class="flex">
  123. <view class="text">申请主体</view>
  124. <view class="flex__auto">
  125. <text v-if="record.subject == 1">个人</text>
  126. <text v-if="record.subject == 2">企业</text>
  127. </view>
  128. </view>
  129. <view class="flex">
  130. <view class="text">发票状态</view>
  131. <view class="flex__auto">
  132. <text class="red" v-if="record.invoiceStatus == 1">未开票</text>
  133. <text class="green" v-if="record.invoiceStatus == 2">已开票</text>
  134. <text class="red" v-if="record.invoiceStatus == -1">已退票</text>
  135. </view>
  136. </view>
  137. <view @click.stop="showOrder(record.checked,index)">
  138. <view class="flex noborder" >
  139. <view class="text">开票订单</view>
  140. <view class="flex__auto">
  141. <text style="margin-right:10rpx;">{{record.orderList.length}}</text>
  142. <u-icon v-if="!record.checked" name="arrow-down" color="#ccc" size="28"></u-icon>
  143. <u-icon v-if="record.checked" name="arrow-up" color="#ccc" size="28"></u-icon>
  144. </view>
  145. </view>
  146. <view class="order-list" v-if="record.checked">
  147. <view class="order-item" :key="orderIndex" v-for="(orderItem,orderIndex) in record.orderList">{{orderIndex+1}}.{{orderItem.goodsName}}</view>
  148. </view>
  149. </view>
  150. </view>
  151. </view>
  152. </view>
  153. </view>
  154. </view>
  155. </view>
  156. <u-popup class="modal" v-model="selectOrderModal" mode="bottom" border-radius="24">
  157. <view class="select-order">
  158. <view class="line"></view>
  159. <view class="title">选择订单</view>
  160. <u-line color="#D6D6DB" />
  161. <view>
  162. <scroll-view scroll-y="true" style="height: 500rpx;">
  163. <view>
  164. <u-checkbox-group>
  165. <view v-for="(item, index) in orderList" :key="index" >
  166. <view class="order-item">
  167. <view>
  168. <u-checkbox
  169. :disabled="item.disabled"
  170. shape="circle"
  171. :name="item.name"
  172. v-model="item.checked"
  173. >
  174. <view class="order-item__bg" :class="item.checked?'active':''" >
  175. <view>
  176. <view class="order-title">{{item.goodsName}}</view>
  177. <view class="order-number">{{item.orderSn}}</view>
  178. <view class="order-price">¥ {{item.goodsPrice}}元</view>
  179. </view>
  180. </view>
  181. </u-checkbox >
  182. </view>
  183. </view>
  184. </view>
  185. </u-checkbox-group>
  186. </view>
  187. </scroll-view>
  188. </view>
  189. <view class="confrim-btn">
  190. <view class="okBtn" @click="okPopup()">确定</view>
  191. </view>
  192. </view>
  193. </u-popup>
  194. <u-popup class="modal" v-model="orderDetailModal" mode="center" border-radius="40">
  195. <view class="order-detail">
  196. <view class="order-detail__content">
  197. <scroll-view scroll-y="true" style="height: 860rpx;">
  198. <view class="content">
  199. <view class="header">{{$method.timestampToTime(invoiceDetail.applyTime,false,false)}}</view>
  200. <view class="body">
  201. <view class="body__item">
  202. <view class="title">发票申请信息</view>
  203. <view class="content">
  204. <u-cell-item :border-bottom="false" hover-class="none" :arrow="false">
  205. <view slot="title">发票类型:</view>
  206. <text v-if="invoiceDetail.type == 1">普通发票</text>
  207. <text v-if="invoiceDetail.type == 2">增值税专用发票</text>
  208. </u-cell-item>
  209. <u-cell-item :border-bottom="false" hover-class="none" :arrow="false">
  210. <view slot="title">申请主体:</view>
  211. <text v-if="invoiceDetail.subject == 1">个人</text>
  212. <text v-if="invoiceDetail.subject == 2">企业</text>
  213. </u-cell-item>
  214. <u-cell-item :border-bottom="false" hover-class="none" :arrow="false">
  215. <view slot="title">发票抬头:</view>
  216. <text>{{invoiceDetail.invoiceTitle}}</text>
  217. </u-cell-item>
  218. <template v-if="invoiceDetail.type == 2">
  219. <u-cell-item :border-bottom="false" hover-class="none" :arrow="false">
  220. <view slot="title">纳税登记号:</view>
  221. <text>{{invoiceDetail.taxRegistryNumber || ''}}</text>
  222. </u-cell-item>
  223. <u-cell-item :border-bottom="false" hover-class="none" :arrow="false">
  224. <view slot="title">单位地址:</view>
  225. <text>{{invoiceDetail.companyAddress || ''}}</text>
  226. </u-cell-item>
  227. <u-cell-item :border-bottom="false" hover-class="none" :arrow="false">
  228. <view slot="title">电话号码:</view>
  229. <text>{{invoiceDetail.phone || ''}}</text>
  230. </u-cell-item>
  231. <u-cell-item :border-bottom="false" hover-class="none" :arrow="false">
  232. <view slot="title">开户银行:</view>
  233. <text>{{invoiceDetail.bankName || ''}}</text>
  234. </u-cell-item>
  235. <u-cell-item :border-bottom="false" hover-class="none" :arrow="false">
  236. <view slot="title">银行账号:</view>
  237. <text>{{invoiceDetail.bankAccount || ''}}</text>
  238. </u-cell-item>
  239. <u-cell-item :border-bottom="false" hover-class="none" :arrow="false">
  240. <view slot="title">收件地址:</view>
  241. <text>{{invoiceDetail.receivingAddress || ''}}</text>
  242. </u-cell-item>
  243. <u-cell-item :border-bottom="false" hover-class="none" :arrow="false">
  244. <view slot="title">收件人:</view>
  245. <text>{{invoiceDetail.receivingName || ''}}</text>
  246. </u-cell-item>
  247. <u-cell-item :border-bottom="false" hover-class="none" :arrow="false" >
  248. <view slot="title">收件手机:</view>
  249. <text>{{invoiceDetail.receivingTel || ''}}</text>
  250. </u-cell-item>
  251. <u-cell-item :border-bottom="false" hover-class="none" :arrow="false" >
  252. <view slot="title">开票订单:</view>
  253. </u-cell-item>
  254. </template>
  255. <view class="order-list">
  256. <view class="order-item" :key="orderIndex" v-for="(orderItem,orderIndex) in invoiceDetail.orderList">
  257. <view class="order-title">{{orderItem.goodsName}}</view>
  258. <view class="order-number">{{orderItem.orderSn}}</view>
  259. <view class="order-price">¥ {{orderItem.goodsRealPrice}}元</view>
  260. </view>
  261. </view>
  262. <view class="order-text">
  263. <view class="order-text__label">本次申请开票金额:</view>
  264. <view class="order-text__price">¥ {{toFixed(invoiceDetail.amount)}}</view>
  265. </view>
  266. </view>
  267. </view>
  268. <view class="body__item">
  269. <view class="title">发票申请结果</view>
  270. <view class="content">
  271. <u-cell-item :border-bottom="false" hover-class="none" :arrow="false">
  272. <view slot="title">审核结果:</view>
  273. <text class="text wait" v-if="invoiceDetail.periodStatus == 1">待审核</text>
  274. <text class="text agree" v-if="invoiceDetail.periodStatus == 3">通过</text>
  275. <text class="text refuse" v-if="invoiceDetail.periodStatus == 2">驳回</text>
  276. </u-cell-item>
  277. <u-cell-item :border-bottom="false" hover-class="none" :arrow="false">
  278. <view slot="title">审核反馈:</view>
  279. <text class="text">{{invoiceDetail.periodReason||''}}</text>
  280. </u-cell-item>
  281. <u-cell-item :border-bottom="false" hover-class="none" :arrow="false">
  282. <view slot="title">发票状态:</view>
  283. <text class="text refuse" v-if="invoiceDetail.invoiceStatus == 1">未开票</text>
  284. <text class="text agree" v-if="invoiceDetail.invoiceStatus == 2">已开票</text>
  285. <text class="text refuse" v-if="invoiceDetail.invoiceStatus == -1">已退票</text>
  286. </u-cell-item>
  287. <u-cell-item :border-bottom="false" hover-class="none" :arrow="false" v-if="invoiceDetail.periodStatus == 3 && (invoiceDetail.invoiceStatus == 2 || invoiceDetail.invoiceStatus == -1) && invoiceDetail.invoiceImg">
  288. <view slot="title">发票预览:</view>
  289. <view>
  290. <image class="preview" @click="previewImg(invoiceDetail)" :src="$method.splitImgHost(invoiceDetail.invoiceImg)"></image>
  291. <view class="download-btn" @click="download(invoiceDetail)">下载电子发票</view>
  292. </view>
  293. </u-cell-item>
  294. <u-cell-item :border-bottom="false" hover-class="none" :arrow="false" v-if="invoiceDetail.periodStatus == 3 && (invoiceDetail.invoiceStatus == 2 || invoiceDetail.invoiceStatus == -1) && invoiceDetail.type == 2 && invoiceDetail.subject == 2">
  295. <view slot="title">机构发票邮寄状态:</view>
  296. <text class="text" v-if="invoiceDetail.sendInvoice == 1">是</text>
  297. <text class="text" v-else>否</text>
  298. </u-cell-item>
  299. <u-cell-item v-if="invoiceDetail.periodStatus == 3 && (invoiceDetail.invoiceStatus == 2 || invoiceDetail.invoiceStatus == -1) && invoiceDetail.sendInvoice == 1 && invoiceDetail.type == 2 && invoiceDetail.subject == 2" @click.stop="copy(invoiceDetail.trackingNum)" :border-bottom="false" hover-class="none" :arrow="false">
  300. <view slot="title">发票邮寄快递单号:(点击可复制)</view>
  301. <text class="text">{{invoiceDetail.trackingNum || ''}}</text>
  302. </u-cell-item>
  303. </view>
  304. </view>
  305. </view>
  306. </view>
  307. </scroll-view>
  308. </view>
  309. <view class="order-detail__btns" v-if="invoiceDetail.periodStatus == 1">
  310. <view class="btn" @click="orderDetailModal = false;">知道了</view>
  311. <view class="btn warm" @click="orderCancelModal = true;">撤销申请</view>
  312. </view>
  313. <view class="order-detail__btns" v-else>
  314. <view class="btn ok" @click="orderDetailModal = false;">知道了</view>
  315. </view>
  316. </view>
  317. </u-popup>
  318. <u-popup class="modal" v-model="orderCancelModal" mode="center" border-radius="24">
  319. <view class="order-cancel">
  320. <view class="header">
  321. 温馨提示
  322. </view>
  323. <view class="body">
  324. <view>撤销申请后,</view>
  325. <view>本次的发票申请内容将不存在。</view>
  326. <view>请慎重考虑。 </view>
  327. <view>您确定要取消本次发票申请吗?</view>
  328. </view>
  329. <view class="footer">
  330. <view class="btn cancel" @click="orderCancelModal = false;">取消</view>
  331. <view class="btn ok" @click="orderCancel()">确定</view>
  332. </view>
  333. </view>
  334. </u-popup>
  335. </view>
  336. </template>
  337. <script>
  338. import { mapGetters } from 'vuex';
  339. export default {
  340. components: {},
  341. data() {
  342. return {
  343. checkOrderList:[],
  344. recordList:[],
  345. list: [
  346. {
  347. name: '发票申请'
  348. },
  349. {
  350. name: '发票记录'
  351. }
  352. ],
  353. invoiceDetail:{
  354. amount:0
  355. },
  356. form:{
  357. type:'1',
  358. subject:'1',
  359. invoiceTitle:'',
  360. orderGoodsIds:'',
  361. taxRegistryNumber:'',
  362. companyAddress:'',
  363. phone:'',
  364. bankName:'',
  365. bankAccount:'',
  366. receivingAddress:'',
  367. receivingName:'',
  368. receivingTel:'',
  369. },
  370. rules: {
  371. receivingTel: [
  372. {
  373. required: true,
  374. message: '请输入收件手机',
  375. // 可以单个或者同时写两个触发验证方式
  376. trigger: ['change'],
  377. },
  378. {
  379. validator: (rule, value, callback) => {
  380. // 上面有说,返回true表示校验通过,返回false表示不通过
  381. // this.$u.test.mobile()就是返回true或者false的
  382. console.log(this.$u.test.mobile(value),'this.$u.test.mobile(value)')
  383. return this.$u.test.mobile(value);
  384. },
  385. message: '手机号码格式不正确',
  386. // 触发器可以同时用blur和change
  387. trigger: ['change'],
  388. }
  389. ],
  390. type: [
  391. {
  392. required: true,
  393. message: '请选择发票类型',
  394. // 可以单个或者同时写两个触发验证方式
  395. trigger: ['change'],
  396. }
  397. ],
  398. subject: [
  399. {
  400. required: true,
  401. message: '请选择申请主体',
  402. // 可以单个或者同时写两个触发验证方式
  403. trigger: ['change'],
  404. }
  405. ],
  406. invoiceTitle: [
  407. {
  408. required: true,
  409. message: '请输入发票抬头',
  410. // 可以单个或者同时写两个触发验证方式
  411. trigger: ['change'],
  412. },
  413. ],
  414. taxRegistryNumber: [
  415. {
  416. required: true,
  417. message: '请输入纳税登记号',
  418. // 可以单个或者同时写两个触发验证方式
  419. trigger: ['change'],
  420. },
  421. {
  422. validator: (rule, value, callback) => {
  423. // 上面有说,返回true表示校验通过,返回false表示不通过
  424. var reg = /(^[0-9A-Z]{15}$)|(^[0-9A-Z]{18}$)|(^[0-9A-Z]{20}$)/;
  425. console.log( reg.test(value),' reg.test(value)')
  426. return reg.test(value);
  427. },
  428. message: '发票抬头格式不正确',
  429. // 触发器可以同时用blur和change
  430. trigger: ['change'],
  431. }
  432. ],
  433. companyAddress: [
  434. {
  435. required: true,
  436. message: '请输入单位地址',
  437. // 可以单个或者同时写两个触发验证方式
  438. trigger: ['change'],
  439. }
  440. ],
  441. phone: [
  442. {
  443. required: true,
  444. message: '请输入电话号码',
  445. // 可以单个或者同时写两个触发验证方式
  446. trigger: ['change'],
  447. },
  448. {
  449. validator: (rule, value, callback) => {
  450. var vartest = /^([0-9]{3,4}-)?[0-9]{7,8}$/;
  451. var vartest1 = /^([0-9]{3,4})?[0-9]{7,8}$/;
  452. if (this.$u.test.mobile(value) || vartest.test(value) || vartest1.test(value)) {
  453. return true;
  454. } else {
  455. return false;
  456. }
  457. },
  458. message: '电话号码不正确',
  459. trigger: ['change', 'blur']
  460. }
  461. ],
  462. bankName: [
  463. {
  464. required: true,
  465. message: '请输入开户银行',
  466. // 可以单个或者同时写两个触发验证方式
  467. trigger: ['change'],
  468. }
  469. ],
  470. bankAccount: [
  471. {
  472. required: true,
  473. message: '请输入银行账号',
  474. // 可以单个或者同时写两个触发验证方式
  475. trigger: ['change'],
  476. },
  477. {
  478. validator: (rule, value, callback) => {
  479. // 上面有说,返回true表示校验通过,返回false表示不通过
  480. var reg = /^[1-9]{1}(\d{15}|\d{18})$/;
  481. console.log( reg.test(value),' reg.test(value)')
  482. return reg.test(value);
  483. },
  484. message: '银行卡号格式不正确',
  485. // 触发器可以同时用blur和change
  486. trigger: ['change'],
  487. }
  488. ],
  489. receivingAddress: [
  490. {
  491. required: true,
  492. message: '请输入收件地址',
  493. // 可以单个或者同时写两个触发验证方式
  494. trigger: ['change'],
  495. }
  496. ],
  497. receivingName: [
  498. {
  499. required: true,
  500. message: '请输入收件人',
  501. // 可以单个或者同时写两个触发验证方式
  502. trigger: ['change'],
  503. }
  504. ],
  505. orderGoodsIds: [
  506. {
  507. required: true,
  508. message: '请选择订单',
  509. // 可以单个或者同时写两个触发验证方式
  510. trigger: ['change'],
  511. }
  512. ],
  513. },
  514. orderValue:'',
  515. orderList:[],
  516. selectOrderModal:false,
  517. orderDetailModal:false,
  518. orderCancelModal:false,
  519. current: 0,
  520. invoicePirce:0,
  521. order: [],
  522. typeList:[{
  523. name:'普通发票',
  524. value:'1'
  525. },{
  526. name:'增值税专用发票',
  527. value:'2'
  528. }],
  529. mainList:[{
  530. name:'个人',
  531. value:'1'
  532. },{
  533. name:'企业',
  534. value:'2'
  535. }]
  536. };
  537. },
  538. // onPullDownRefresh() {},
  539. onLoad(option) {
  540. this.orderInvoiceCanInvoiceList();
  541. this.$refs.uForm.setRules(this.rules)
  542. },
  543. onShow() {
  544. },
  545. methods: {
  546. orderCancel() {
  547. let invoiceDetail = JSON.parse(JSON.stringify(this.invoiceDetail))
  548. invoiceDetail.status = -1;
  549. this.$api.orderInvoiceCancel(invoiceDetail).then(res => {
  550. if(res.data.code == 200) {
  551. this.orderInvoiceList();
  552. this.orderInvoiceCanInvoiceList();
  553. this.orderDetailModal = false;
  554. this.orderCancelModal = false;
  555. uni.showToast({
  556. title:'撤销成功',
  557. icon:'none'
  558. })
  559. } else {
  560. }
  561. })
  562. },
  563. showDetailModal(item) {
  564. this.orderDetailModal = true;
  565. this.invoiceDetail = item;
  566. },
  567. toFixed(number) {
  568. console.log(number.toFixed(2))
  569. return number.toFixed(2)
  570. },
  571. /**
  572. * 获取可开发票的订单
  573. */
  574. orderInvoiceCanInvoiceList() {
  575. this.$api.orderInvoiceCanInvoiceList().then(res => {
  576. if(res.data.code == 200) {
  577. res.data.rows.forEach(item => {
  578. item.checked = false;
  579. })
  580. this.orderList = res.data.rows;
  581. }
  582. })
  583. },
  584. /**
  585. * @param {Object} checkedState 显示状态
  586. * @param {Object} index 索引值
  587. * 修改开票订单列表显示状态
  588. */
  589. showOrder(showState,index) {
  590. this.$set(this.recordList[index],'checked',!showState)
  591. },
  592. /**
  593. * 发票申请提交
  594. */
  595. formSubmit() {
  596. this.$refs.uForm.validate(valid => {
  597. console.log(valid,'valid')
  598. console.log(this.form,'this.form')
  599. if(valid) {
  600. if(this.invoicePirce > 10000) {
  601. uni.showModal({
  602. title:'提示',
  603. content:'您所选的订单总开票金额,大于10000元,超出单张发票的开票额度,请修改开票订单',
  604. showCancel:false,
  605. })
  606. return
  607. }
  608. let data = JSON.parse(JSON.stringify(this.form));
  609. data.orderGoodsIds = data.orderGoodsIds.split(',')
  610. data.amount = this.invoicePirce;
  611. if(data.subject == '1') {
  612. data.taxRegistryNumber = '';
  613. data.companyAddress = '';
  614. data.phone = '';
  615. data.bankName = '';
  616. data.bankAccount = '';
  617. data.receivingAddress = '';
  618. data.receivingName = '';
  619. data.receivingTel = '';
  620. }
  621. this.$api.orderInvoice(data).then(res => {
  622. if(res.data.code == 200) {
  623. this.orderInvoiceCanInvoiceList();
  624. this.form = {
  625. type:'1',
  626. subject:'1',
  627. invoiceTitle:'',
  628. orderGoodsIds:'',
  629. taxRegistryNumber:'',
  630. companyAddress:'',
  631. phone:'',
  632. bankName:'',
  633. bankAccount:'',
  634. receivingAddress:'',
  635. receivingName:'',
  636. receivingTel:'',
  637. };
  638. this.invoicePirce = 0;
  639. uni.showModal({
  640. title:'操作提示',
  641. content:`您本次的发票申请已经提交成功!\n机构将在3-7个工作日内进行处理,处理结果会在【发票记录】显示,请留意进度。`,
  642. showCancel:false,
  643. confirmText:'知道了'
  644. })
  645. } else {
  646. uni.showToast({
  647. icon:'none',
  648. title:res.data.msg
  649. })
  650. }
  651. })
  652. }
  653. })
  654. },
  655. /**
  656. * @param {Object} e value
  657. * 发票类型修改
  658. */
  659. formTypeChange(e) {
  660. console.log(e)
  661. if(e == '2') {
  662. this.$set(this.form,'subject','2')
  663. } else {
  664. }
  665. },
  666. /**
  667. * @param {Object} e
  668. * tabs 切换
  669. */
  670. change(e) {
  671. console.log(e)
  672. this.current = e;
  673. if(this.current == 1) {
  674. this.orderInvoiceList();
  675. } else {
  676. this.$nextTick(() => {
  677. this.$refs.uForm.setRules(this.rules)
  678. })
  679. }
  680. },
  681. orderInvoiceList() {
  682. this.$api.orderInvoiceList().then(res => {
  683. if(res.data.code == 200) {
  684. this.recordList = res.data.rows
  685. } else {
  686. uni.showToast({
  687. icon:'none',
  688. title:res.data.msg
  689. })
  690. }
  691. })
  692. },
  693. radioGroupChange(e) {
  694. console.log(e)
  695. },
  696. copy(str) {
  697. if(!str) {
  698. uni.showToast({
  699. icon:'none',
  700. title:'暂时没有可以复制的快递号'
  701. })
  702. return;
  703. }
  704. let newStr = String(str)
  705. uni.setClipboardData({
  706. data: newStr,
  707. success: function () {
  708. console.log('success');
  709. }
  710. });
  711. },
  712. okPopup() {
  713. this.selectOrderModal = false;
  714. let strArr = [];
  715. this.invoicePirce = 0;
  716. this.orderList.forEach((item,index) => {
  717. if(item.checked) {
  718. this.$set(this.orderList[index],'disabled',true)
  719. strArr.push(item.orderGoodsId)
  720. this.invoicePirce += item.goodsPrice
  721. }
  722. })
  723. this.form.orderGoodsIds = strArr.join(',')
  724. this.$nextTick(() => {
  725. this.$refs.orderGoodsIds.onFieldChange()
  726. })
  727. console.log(this.$refs.orderGoodsIds)
  728. },
  729. deleteOrder(index) {
  730. this.$set(this.orderList[index],'disabled',false)
  731. this.$set(this.orderList[index],'checked',false)
  732. let strArr = [];
  733. this.invoicePirce = 0;
  734. this.orderList.forEach((item,index) => {
  735. if(item.checked) {
  736. strArr.push(item.orderGoodsId)
  737. this.invoicePirce += item.goodsPrice
  738. }
  739. })
  740. this.form.orderGoodsIds = strArr.join(',')
  741. this.$nextTick(() => {
  742. this.$refs.orderGoodsIds.onFieldChange()
  743. })
  744. },
  745. previewImg(item) {
  746. // 预览图片
  747. uni.previewImage({
  748. urls: [this.$method.splitImgHost(item.invoiceImg,true,1000)],
  749. longPressActions: {
  750. itemList: ['发送给朋友', '保存图片', '收藏'],
  751. success: function(data) {
  752. console.log('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
  753. },
  754. fail: function(err) {
  755. console.log(err.errMsg);
  756. }
  757. }
  758. });
  759. },
  760. download(item) {
  761. //获取相册授权
  762. uni.getSetting({
  763. success:(res) => {
  764. if (!res.authSetting['scope.writePhotosAlbum']) {
  765. uni.authorize({
  766. scope: 'scope.writePhotosAlbum',
  767. success() {
  768. //这里是用户同意授权后的回调
  769. this.saveImgToLocal(item);
  770. },
  771. fail() {//这里是用户拒绝授权后的回调
  772. }
  773. })
  774. } else {//用户已经授权过了
  775. this.saveImgToLocal(item);
  776. }
  777. }
  778. })
  779. },
  780. saveImgToLocal(item){
  781. uni.showModal({
  782. title: '提示',
  783. content: '确定保存到相册吗',
  784. success: (res) => {
  785. if (res.confirm) {
  786. uni.downloadFile({
  787. url: this.$method.splitImgHost(item.invoiceImg,true,1000),//图片地址
  788. success: (res) =>{
  789. if (res.statusCode === 200){
  790. uni.saveImageToPhotosAlbum({
  791. filePath: res.tempFilePath,
  792. success: function() {
  793. uni.showToast({
  794. title: "保存成功",
  795. icon: "none"
  796. });
  797. },
  798. fail: function() {
  799. uni.showToast({
  800. title: "保存失败",
  801. icon: "none"
  802. });
  803. }
  804. });
  805. }
  806. }
  807. })
  808. } else if (res.cancel) {
  809. }
  810. }
  811. });
  812. }
  813. },
  814. computed: { ...mapGetters(['userInfo']) }
  815. };
  816. </script>
  817. <style>
  818. page {
  819. background: #eaeef1;
  820. }
  821. </style>
  822. <style scoped lang="scss">
  823. .invoice {
  824. &__tabs {
  825. width: 100%;
  826. text-align: center;
  827. position: fixed;
  828. height: 96rpx;
  829. z-index: 999;
  830. }
  831. &__content {
  832. padding-top:96rpx;
  833. .open {
  834. padding-bottom:150rpx;
  835. margin:8rpx 24rpx 0;
  836. .form {
  837. padding:24rpx;
  838. width: 702rpx;
  839. background: #FFFFFF;
  840. border-radius: 24rpx;
  841. // /deep/ .u-input__input {
  842. // text-align: right;
  843. // }
  844. .form-item {
  845. height:78rpx;
  846. display: flex;
  847. align-items: center;
  848. .text {
  849. font-size: 28rpx;
  850. width:120rpx;
  851. // color: #999999;
  852. }
  853. .content {
  854. flex:1;
  855. text-align: left;
  856. color:#bbb;
  857. }
  858. }
  859. .check-order {
  860. margin-top:20rpx;
  861. width: 654rpx;
  862. height: 168rpx;
  863. background: #F5F5F5;
  864. border: 2px solid #F5F5F5;
  865. padding:20rpx;
  866. position:relative;
  867. .close {
  868. position:absolute;
  869. right:0;
  870. top:0;
  871. }
  872. .title,.number,.price {
  873. color:#333333;
  874. margin-top:10rpx;
  875. line-height: 30rpx;
  876. font-size: 30rpx;
  877. }
  878. .number {
  879. color:#999;
  880. }
  881. }
  882. }
  883. .order-text {
  884. margin-top:16rpx;
  885. padding:0 30rpx;
  886. width: 702rpx;
  887. height: 80rpx;
  888. background: #FFFFFF;
  889. border-radius: 24rpx;
  890. display: flex;
  891. align-items: center;
  892. &__label {
  893. font-size: 24rpx;
  894. }
  895. &__price {
  896. font-size: 30rpx;
  897. margin-left:20rpx;
  898. color:#FF2D55;
  899. }
  900. }
  901. .submit {
  902. text-align: center;
  903. line-height: 80rpx;
  904. color:#fff;
  905. font-size: 30rpx;
  906. width: 526rpx;
  907. height: 80rpx;
  908. background: #007AFF;
  909. box-shadow: 0rpx 8rpx 7rpx 1rpx rgba(0, 122, 255, 0.1);
  910. border-radius: 40rpx;
  911. position:fixed;
  912. left:50%;
  913. bottom:40rpx;
  914. z-index: 999;
  915. transform: translateX(-50%);
  916. }
  917. }
  918. .record {
  919. .nodata {
  920. padding-top:160rpx;
  921. font-size: 32rpx;
  922. text-align: center;
  923. color: #999999;
  924. }
  925. &__list {
  926. .record-item {
  927. margin:0 8rpx 10rpx;
  928. .item__time {
  929. padding:20rpx 0;
  930. text-align: center;
  931. font-size: 24rpx;
  932. color: #999999;
  933. }
  934. .item__content {
  935. background:#fff;
  936. border-radius: 16rpx;
  937. .top {
  938. padding:12rpx 0;
  939. border-bottom:1px solid #EEEEEE;
  940. .state {
  941. position:relative;
  942. text-align: center;
  943. color:#fff;
  944. font-size: 30rpx;
  945. margin:0 auto;
  946. width: 240rpx;
  947. height: 56rpx;
  948. line-height: 56rpx;
  949. background: #007AFF;
  950. border-radius: 28rpx;
  951. &.wait {
  952. background: #007AFF;
  953. }
  954. &.refuse {
  955. background: #FF3B30;
  956. }
  957. &.agree {
  958. background: #34C759;
  959. }
  960. .arrow {
  961. position:absolute;
  962. top:50%;
  963. transform: translateY(-50%);
  964. right:18rpx;
  965. }
  966. }
  967. }
  968. .bottom {
  969. padding:0 32rpx;
  970. .flex {
  971. height:80rpx;
  972. display: flex;
  973. align-items: center;
  974. border-bottom:1px solid #EEEEEE;
  975. &.noborder{
  976. border:0;
  977. }
  978. .text {
  979. font-size: 24rpx;
  980. color: #666666;
  981. }
  982. &__auto {
  983. text-align: right;
  984. flex:1;
  985. font-size: 30rpx;
  986. font-weight: bold;
  987. color: #666666;
  988. .red {
  989. color:#FF3B30;
  990. }
  991. .green {
  992. color:#34C759;
  993. }
  994. }
  995. }
  996. .order-list {
  997. padding-bottom:30rpx;
  998. .order-item {
  999. border-radius: 16rpx;
  1000. padding:14rpx;
  1001. background:#F5F5F5;
  1002. font-size: 30rpx;
  1003. color:#333;
  1004. margin-top:16rpx;
  1005. }
  1006. }
  1007. }
  1008. }
  1009. }
  1010. }
  1011. }
  1012. }
  1013. .modal {
  1014. .select-order {
  1015. .line {
  1016. width: 80rpx;
  1017. height: 8rpx;
  1018. background: #999999;
  1019. border-radius: 4rpx;
  1020. margin:8rpx auto 0;
  1021. }
  1022. .title {
  1023. margin:20rpx 0 15rpx;
  1024. text-align: center;
  1025. font-size: 24rpx;
  1026. color: #999999;
  1027. }
  1028. .order-item {
  1029. display: flex;
  1030. align-items: center;
  1031. padding: 20rpx;
  1032. &__bg {
  1033. width: 654rpx;
  1034. height: 168rpx;
  1035. background: #F5F5F5;
  1036. border: 2px solid #F5F5F5;
  1037. border-radius: 16rpx;
  1038. padding:20rpx;
  1039. &.active {
  1040. background: #EBF5FF;
  1041. border: 2px solid #007AFF;
  1042. }
  1043. .order-title,.order-number,.order-price {
  1044. color:#333333;
  1045. margin-top:10rpx;
  1046. line-height: 30rpx;
  1047. font-size: 30rpx;
  1048. }
  1049. .order-number {
  1050. color:#999;
  1051. }
  1052. }
  1053. }
  1054. .confrim-btn {
  1055. width: 750rpx;
  1056. height: 98rpx;
  1057. background: rgba(255, 255, 255, 0.98);
  1058. display: flex;
  1059. align-items: center;
  1060. justify-content: center;
  1061. .okBtn {
  1062. text-align: center;
  1063. line-height: 64rpx;
  1064. color:#fff;
  1065. font-size: 30rpx;
  1066. width: 200rpx;
  1067. height: 64rpx;
  1068. background: linear-gradient(0deg, #015EEA, #00C0FA);
  1069. border-radius: 32rpx;
  1070. }
  1071. }
  1072. }
  1073. .order-detail {
  1074. width: 640rpx;
  1075. height: 1000rpx;
  1076. background: #FFFFFF;
  1077. display: flex;
  1078. flex-direction: column;
  1079. &__content {
  1080. flex:1;
  1081. .content {
  1082. padding:24rpx 24rpx 0;
  1083. /deep/ .u-cell {
  1084. padding:10rpx;
  1085. &_title {
  1086. color:#999;
  1087. }
  1088. &__value {
  1089. color:#333;
  1090. text-align: left;
  1091. }
  1092. .text {
  1093. &.wait {
  1094. color:#007AFF;
  1095. }
  1096. &.agree {
  1097. color:#34C759;
  1098. }
  1099. &.refuse {
  1100. color:#FF3B30;
  1101. }
  1102. }
  1103. .preview {
  1104. width:240rpx;
  1105. height:160rpx;
  1106. }
  1107. .download-btn {
  1108. margin:10rpx 0 0;
  1109. text-align: center;
  1110. line-height: 56rpx;
  1111. color:#fff;
  1112. font-size: 30rpx;
  1113. width: 224rpx;
  1114. height: 56rpx;
  1115. background: #007AFF;
  1116. border-radius: 16rpx;
  1117. }
  1118. }
  1119. .header {
  1120. font-size: 30rpx;
  1121. font-weight: bold;
  1122. color: #333333;
  1123. line-height: 48rpx;
  1124. }
  1125. .body {
  1126. &__item {
  1127. border-bottom:1px solid #EEEEEE;
  1128. padding-bottom:30rpx;
  1129. &:last-child {
  1130. border:0;
  1131. }
  1132. .title {
  1133. margin-top:30rpx;
  1134. font-size: 24rpx;
  1135. color: #007AFF;
  1136. line-height: 48rpx;
  1137. &::before {
  1138. content:'';
  1139. width: 4rpx;
  1140. height: 24rpx;
  1141. background: #007AFF;
  1142. border-radius: 2rpx;
  1143. display: inline-block;
  1144. margin-right:10rpx;
  1145. }
  1146. }
  1147. .order-list {
  1148. .order-item {
  1149. overflow: hidden;
  1150. border-radius: 16rpx;
  1151. padding:0 14rpx 14rpx;
  1152. background:#F5F5F5;
  1153. font-size: 30rpx;
  1154. color:#333;
  1155. margin-top:16rpx;
  1156. .order-title,.order-number,.order-price {
  1157. color:#333333;
  1158. margin-top:20rpx;
  1159. line-height: 26rpx;
  1160. font-size: 26rpx;
  1161. }
  1162. .order-number {
  1163. color:#999;
  1164. }
  1165. }
  1166. }
  1167. .order-text {
  1168. margin-top:16rpx;
  1169. padding:0 30rpx;
  1170. height: 80rpx;
  1171. background: #F5F5F5;
  1172. border-radius: 16rpx;
  1173. display: flex;
  1174. align-items: center;
  1175. &__label {
  1176. font-size: 24rpx;
  1177. color:#999999;
  1178. }
  1179. &__price {
  1180. font-size: 30rpx;
  1181. margin-left:20rpx;
  1182. color:#FF2D55;
  1183. }
  1184. }
  1185. }
  1186. }
  1187. }
  1188. }
  1189. &__btns {
  1190. border-top:1px solid #EEEEEE;
  1191. padding:0 24rpx;
  1192. width: 100%;
  1193. height: 140rpx;
  1194. background: #FFFFFF;
  1195. display: flex;
  1196. justify-content: center;
  1197. align-items: center;
  1198. .btn {
  1199. text-align: center;
  1200. width: 200rpx;
  1201. height: 80rpx;
  1202. line-height: 80rpx;
  1203. background: #F5F5F5;
  1204. border-radius: 40rpx;
  1205. color:#007AFF;
  1206. font-size: 30rpx;
  1207. margin:0 10rpx;
  1208. &.warm {
  1209. background: #FF3B30;
  1210. color:#fff;
  1211. }
  1212. &.ok {
  1213. color:#fff;
  1214. width: 526rpx;
  1215. height: 80rpx;
  1216. background: #007AFF;
  1217. border-radius: 40rpx;
  1218. }
  1219. }
  1220. }
  1221. }
  1222. .order-cancel {
  1223. width: 640rpx;
  1224. height: 439rpx;
  1225. background: #FFFFFF;
  1226. padding:40rpx;
  1227. .header {
  1228. text-align: center;
  1229. font-size: 30rpx;
  1230. font-weight: bold;
  1231. color: #333333;
  1232. line-height: 48rpx;
  1233. }
  1234. .body {
  1235. margin-top:40rpx;
  1236. view {
  1237. font-size: 30rpx;
  1238. color: #666666;
  1239. line-height: 48rpx;
  1240. }
  1241. }
  1242. .footer {
  1243. margin-top:40rpx;
  1244. display: flex;
  1245. align-items: center;
  1246. justify-content: center;
  1247. .btn {
  1248. text-align: center;
  1249. line-height: 80rpx;
  1250. font-size: 30rpx;
  1251. color:#007AFF;
  1252. width: 200rpx;
  1253. height: 80rpx;
  1254. background: #F5F5F5;
  1255. border-radius: 40rpx;
  1256. margin:0 10rpx;
  1257. &.ok {
  1258. color:#fff;
  1259. background: #007AFF;
  1260. }
  1261. }
  1262. }
  1263. }
  1264. }
  1265. }
  1266. </style>