parkingChangeHeader.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368
  1. <template>
  2. <scroll-view class="scroll-Y" scroll-y>
  3. <wx-points-commit ref="wxPointsCommit"></wx-points-commit>
  4. <view class="part top">
  5. <view class="invoice-header">
  6. <view class="part-item header-type lines">
  7. <text class="part-item-key">抬头类型</text>
  8. <radio-group class="part-item-value" @change="radioChange">
  9. <label v-for="(item, index) in items" :key="item.value">
  10. <radio
  11. style="transform: scale(0.7)"
  12. color="#ED1C24"
  13. :value="item.value"
  14. :checked="index === condition.invoiceTitleType"
  15. />
  16. {{ item.name }}
  17. </label>
  18. </radio-group>
  19. </view>
  20. <view class="part-item lines">
  21. <text class="part-item-key">抬头名称</text>
  22. <view class="part-item-value">
  23. <input
  24. type="text"
  25. placeholder="请输入抬头名称"
  26. v-model="condition.invoiceTitleName"
  27. />
  28. </view>
  29. </view>
  30. <view class="part-item lines" v-if="isCompany">
  31. <text class="part-item-key">公司税号</text>
  32. <view class="part-item-value">
  33. <input
  34. type="text"
  35. placeholder="请输入公司税号"
  36. v-model="condition.corporationTax"
  37. />
  38. </view>
  39. </view>
  40. <view class="part-item lines">
  41. <text class="part-item-key">设为默认</text>
  42. <view class="part-item-value">
  43. <switch
  44. color="#8CC63F"
  45. :checked="isDefault"
  46. @change="switch1Change"
  47. />
  48. </view>
  49. </view>
  50. </view>
  51. <view class="invoice-more" v-if="isCompany">
  52. <view class="tab-title">更多信息(以下为选填内容)</view>
  53. <view class="part-item lines">
  54. <text class="part-item-key">公司地址</text>
  55. <view class="part-item-value">
  56. <input
  57. type="text"
  58. placeholder="请输入公司地址"
  59. v-model="condition.companyAddress"
  60. />
  61. </view>
  62. </view>
  63. <view class="part-item lines">
  64. <text class="part-item-key">公司电话</text>
  65. <view class="part-item-value">
  66. <input
  67. type="text"
  68. placeholder="请输入公司电话"
  69. v-model="condition.companyTel"
  70. />
  71. </view>
  72. </view>
  73. <view class="part-item lines">
  74. <text class="part-item-key">开户银行</text>
  75. <view class="part-item-value">
  76. <input
  77. type="text"
  78. placeholder="请输入开户银行"
  79. v-model="condition.depositBank"
  80. />
  81. </view>
  82. </view>
  83. <view class="part-item lines" style="border: none">
  84. <text class="part-item-key">开户账户</text>
  85. <view class="part-item-value">
  86. <input
  87. type="text"
  88. placeholder="请输入开户银行"
  89. v-model="condition.accountNumber"
  90. />
  91. </view>
  92. </view>
  93. </view>
  94. </view>
  95. <!-- <view class="part middle">
  96. <view class="part-item">
  97. <text class="part-item-key">总金额</text>
  98. <text class="part-item-value"><text class="purple">10.00</text>元</text>
  99. </view>
  100. </view> -->
  101. <view class="part footer">
  102. <!-- <view class="tab-title">接收方式</view>
  103. <view class="part-item lines">
  104. <text class="part-item-key">电子邮箱</text>
  105. <text class="part-item-value">sota_xu@hafengkeji.com</text>
  106. </view> -->
  107. <view
  108. :class="{
  109. 'push-again-btn': true,
  110. 'blue-push-again-btn': custTypeId === 1,
  111. 'green-push-again-btn': custTypeId === 2,
  112. }"
  113. @click="submit"
  114. >保存</view
  115. >
  116. </view>
  117. </scroll-view>
  118. </template>
  119. <script>
  120. const app = getApp();
  121. import { mapState } from 'vuex';
  122. import MemberCacheTool from '@/utils/member-cache-tool.js';
  123. export default {
  124. data() {
  125. return {
  126. picUrl: this.$picUrl,
  127. type: 'add',
  128. id: '',
  129. globalData: app.globalData,
  130. items: [
  131. { value: '0', name: '单位' },
  132. { value: '1', name: '个人/非企业单位' },
  133. ],
  134. isDefault: true, // 记录
  135. condition: {
  136. id: '', // |Long|否|抬头id
  137. invoiceTitleType: 0, // |int|是|抬头类型( 0:单位,1:个人/非企业单位)
  138. invoiceTitleName: '', // |String|是|抬头名称
  139. corporationTax: '', // |String|是|公司税号|
  140. setDefault: '', // |int|是|设为默认(0:不默认,1:默认)
  141. depositBank: '', // |String|否|开户银行
  142. accountNumber: '', // |String|否|开户账号
  143. companyAddress: '', // |String|否|公司地址
  144. companyTel: '', // |String|否|公司电话
  145. createUser: '', // |String|是|创建人
  146. creator: '', // |Long|是|创建者id
  147. updateUser: app.globalData.wxMember.nickname, // |String|是|更新人
  148. updater: app.globalData.wxMember.id, // |Long|是|更新人id
  149. mobile: app.globalData.wxMember.mobile, // |String|是|手机号
  150. vipcode: app.globalData.member.vipcode, // |String|是|会员号
  151. openid: MemberCacheTool.getOpenId(app), // |String|是|openid
  152. },
  153. preUrl: '',
  154. };
  155. },
  156. computed: {
  157. isCompany: function () {
  158. return this.condition.invoiceTitleType == 0;
  159. },
  160. ...mapState({
  161. custTypeId: (state) => state.custTypeId,
  162. }),
  163. },
  164. onLoad(options) {
  165. console.log(this.globalData);
  166. if (options.type) this.type = options.type;
  167. if (options.id) (this.id = options.id), this.getInvoiceTitleById();
  168. // 埋点本地化
  169. this.preUrl = uni.getStorageSync('previousUrl');
  170. uni.setStorageSync(
  171. 'previousUrl',
  172. '/pages/parkingFee/parkingReceipt/parkingChangeHeader.vue'
  173. );
  174. },
  175. methods: {
  176. radioChange: function (e) {
  177. for (let i = 0; i < this.items.length; i++) {
  178. if (this.items[i].value === e.detail.value) {
  179. this.condition.invoiceTitleType = i;
  180. break;
  181. }
  182. }
  183. },
  184. switch1Change: function (e) {
  185. console.log('switch1 发生 change 事件,携带值为', e.target.value);
  186. this.isDefault = e.target.value;
  187. },
  188. // 根据抬头ID获取抬头详情信息 api/1.0/invoiceTitle/{id}
  189. getInvoiceTitleById() {
  190. const self = this;
  191. const params = {
  192. id: this.id,
  193. };
  194. self.$md(params);
  195. uni.request({
  196. url: self.$baseURL + 'api/1.0/invoiceTitle/' + this.id,
  197. method: 'GET',
  198. data: params,
  199. header: JSON.parse(uni.getStorageSync('handleUser')),
  200. success: (res) => {
  201. console.log('获取抬头详情信息', res.data);
  202. if (res.data.code === 0) {
  203. self.condition = res.data.data;
  204. // 单独对默认选项进行赋值
  205. self.isDefault = res.data.data.setDefault === 1 ? true : false;
  206. } else {
  207. uni.showToast({
  208. title: res.data.msg,
  209. duration: 2000,
  210. icon: 'none',
  211. });
  212. }
  213. },
  214. fail: () => {
  215. uni.showToast({
  216. title: '服务器开小差了呢,请您稍后再试',
  217. icon: 'none',
  218. });
  219. },
  220. });
  221. },
  222. // 添加、编辑抬头信息
  223. submit() {
  224. const self = this;
  225. const url =
  226. self.type === 'add' ? 'api/1.0/invoiceTitle' : 'api/1.0/invoiceTitle';
  227. const methodType = self.type === 'add' ? 'POST' : 'PUT';
  228. if (self.type === 'add') {
  229. self.condition.createUser = self.globalData.wxMember.nickname;
  230. self.condition.creator = self.globalData.wxMember.id;
  231. }
  232. self.condition.setDefault = self.isDefault ? 1 : 0;
  233. const params = {
  234. ...self.condition,
  235. };
  236. console.log('提交信息', params);
  237. self.$md(params);
  238. uni.request({
  239. url: self.$baseURL + url,
  240. method: methodType,
  241. data: params,
  242. header: JSON.parse(uni.getStorageSync('handleUser')),
  243. success: (res) => {
  244. console.log(res.data);
  245. if (res.data.code === 0) {
  246. uni.navigateBack({ delta: 1 });
  247. } else {
  248. uni.showToast({
  249. title: res.data.msg,
  250. duration: 2000,
  251. icon: 'none',
  252. });
  253. }
  254. },
  255. fail: () => {
  256. uni.showToast({
  257. title: '服务器开小差了呢,请您稍后再试',
  258. icon: 'none',
  259. });
  260. },
  261. });
  262. },
  263. },
  264. };
  265. </script>
  266. <style lang="less" scoped>
  267. @import '../../../styles/common.less';
  268. .scroll-Y {
  269. width: 100%;
  270. display: flex;
  271. flex-direction: column;
  272. height: 100vh;
  273. background: #f2f2f2;
  274. .part {
  275. background-color: #ffffff;
  276. .part-item {
  277. display: flex;
  278. justify-content: space-between;
  279. align-items: center;
  280. // padding: 32rpx 0;
  281. font-size: 28rpx;
  282. width: 91.4%;
  283. height: 87rpx;
  284. margin: 0 auto;
  285. .part-item-key {
  286. color: #333;
  287. }
  288. .part-item-value {
  289. color: #999;
  290. text-align: right;
  291. > label {
  292. margin-left: 20rpx;
  293. }
  294. }
  295. }
  296. .tab-title {
  297. color: #676767;
  298. padding: 30rpx 35rpx;
  299. background-color: #f1f1f1;
  300. }
  301. .lines {
  302. border-bottom: 2rpx solid #ececec;
  303. }
  304. .invoice-more {
  305. padding-bottom: 8rpx;
  306. }
  307. }
  308. .top {
  309. padding-top: 20rpx;
  310. }
  311. .middle {
  312. margin: 20rpx 0;
  313. .purple {
  314. color: #a668b1;
  315. }
  316. }
  317. .footer {
  318. width: 100%;
  319. height: 110rpx;
  320. position: fixed;
  321. bottom: 0rpx;
  322. // padding-bottom: constant(safe-area-inset-bottom);
  323. // padding-bottom: env(safe-area-inset-bottom);
  324. padding-bottom: 20rpx;
  325. box-shadow: 0 0 10px 0 hsla(0, 6%, 58%, 0.6);
  326. -webkit-box-shadow: 0 0 20rpx 0 hsla(0, 6%, 58%, 0.6);
  327. -moz-box-shadow: 0 0 20rpx 0 hsla(0, 6%, 58%, 0.6);
  328. // padding-top: 20rpx;
  329. .invoive-img {
  330. text-align: center;
  331. > image {
  332. width: 100%;
  333. }
  334. .download {
  335. margin-top: 20rpx;
  336. margin-bottom: 20rpx;
  337. display: flex;
  338. justify-content: center;
  339. align-items: center;
  340. > image {
  341. width: 32rpx;
  342. }
  343. > text {
  344. margin-left: 10rpx;
  345. color: #808080;
  346. }
  347. }
  348. }
  349. .push-again-btn {
  350. margin: 25rpx 30rpx;
  351. background-image: linear-gradient(to right, #7d4ea1, #40397c);
  352. border-radius: 50rpx;
  353. color: #ffffff;
  354. text-align: center;
  355. padding: 25rpx 0;
  356. }
  357. .blue-push-again-btn {
  358. .color-background-color('blue');
  359. }
  360. .green-push-again-btn {
  361. .color-background-color('green');
  362. }
  363. }
  364. }
  365. </style>