edit.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. "use strict";
  2. const common_vendor = require("../../../common/vendor.js");
  3. const sheep_index = require("../../../sheep/index.js");
  4. require("../../../sheep/request/index.js");
  5. const sheep_api_member_address = require("../../../sheep/api/member/address.js");
  6. require("../../../sheep/helper/index.js");
  7. require("../../../sheep/url/index.js");
  8. require("../../../sheep/store/index.js");
  9. require("../../../sheep/store/app.js");
  10. require("../../../sheep/api/promotion/diy.js");
  11. require("../../../sheep/platform/index.js");
  12. require("../../../sheep/platform/provider/wechat/index.js");
  13. require("../../../sheep/platform/provider/wechat/miniProgram.js");
  14. require("../../../sheep/api/member/auth.js");
  15. require("../../../sheep/api/member/social.js");
  16. require("../../../sheep/api/member/user.js");
  17. require("../../../sheep/platform/provider/apple/index.js");
  18. require("../../../sheep/platform/share.js");
  19. require("../../../sheep/router/index.js");
  20. require("../../../sheep/hooks/useModal.js");
  21. require("../../../sheep/helper/test.js");
  22. require("../../../sheep/api/member/signin.js");
  23. require("../../../sheep/helper/throttle.js");
  24. require("../../../sheep/platform/pay.js");
  25. require("../../../sheep/api/pay/order.js");
  26. require("../../../sheep/store/user.js");
  27. require("../../../sheep/store/cart.js");
  28. require("../../../sheep/api/trade/cart.js");
  29. require("../../../sheep/api/pay/wallet.js");
  30. require("../../../sheep/api/trade/order.js");
  31. require("../../../sheep/api/promotion/coupon.js");
  32. require("../../../sheep/store/sys.js");
  33. require("../../../sheep/store/modal.js");
  34. require("../../../sheep/config/index.js");
  35. require("../../../sheep/config/zIndex.js");
  36. require("../../../sheep/helper/digit.js");
  37. if (!Array) {
  38. const _easycom_uni_forms_item2 = common_vendor.resolveComponent("uni-forms-item");
  39. const _easycom_uni_easyinput2 = common_vendor.resolveComponent("uni-easyinput");
  40. const _easycom_uni_forms2 = common_vendor.resolveComponent("uni-forms");
  41. const _easycom_su_fixed2 = common_vendor.resolveComponent("su-fixed");
  42. const _easycom_s_layout2 = common_vendor.resolveComponent("s-layout");
  43. (_easycom_uni_forms_item2 + _easycom_uni_easyinput2 + _easycom_uni_forms2 + _easycom_su_fixed2 + _easycom_s_layout2)();
  44. }
  45. const _easycom_uni_forms_item = () => "../../../uni_modules/uni-forms/components/uni-forms-item/uni-forms-item.js";
  46. const _easycom_uni_easyinput = () => "../../../uni_modules/uni-easyinput/components/uni-easyinput/uni-easyinput.js";
  47. const _easycom_uni_forms = () => "../../../uni_modules/uni-forms/components/uni-forms/uni-forms.js";
  48. const _easycom_su_fixed = () => "../../../sheep/ui/su-fixed/su-fixed.js";
  49. const _easycom_s_layout = () => "../../../sheep/components/s-layout/s-layout.js";
  50. if (!Math) {
  51. (_easycom_uni_forms_item + _easycom_uni_easyinput + _easycom_uni_forms + _easycom_su_fixed + _easycom_s_layout)();
  52. }
  53. const _sfc_main = {
  54. __name: "edit",
  55. setup(__props) {
  56. const invoiceFormRef = common_vendor.ref(null);
  57. const currentProtocol = common_vendor.ref(false);
  58. const state = common_vendor.reactive({
  59. showRegion: false,
  60. model: {
  61. invoiceType: 1,
  62. invoiceTitleType: 1,
  63. invoiceTitle: "",
  64. taxIDNumber: ""
  65. },
  66. rules: {},
  67. protocol: false
  68. });
  69. function onChange() {
  70. state.protocol = !state.protocol;
  71. }
  72. function onProtocol(title) {
  73. sheep_index.sheep.$router.go("/pages/public/richtext", {
  74. title
  75. });
  76. }
  77. const rules = {
  78. invoiceType: {
  79. rules: [{
  80. required: true,
  81. errorMessage: "请选择发票类型"
  82. }]
  83. },
  84. invoiceTitleType: {
  85. rules: [{
  86. required: true,
  87. errorMessage: "请选择抬头类型"
  88. }]
  89. },
  90. invoiceTitle: {
  91. rules: [{
  92. required: true,
  93. errorMessage: "请输入发票抬头"
  94. }]
  95. },
  96. taxIDNumber: {
  97. rules: [{
  98. required: true,
  99. errorMessage: "请输入单位税号"
  100. }]
  101. }
  102. };
  103. const invoiceType = (e) => {
  104. state.model.invoiceType = e.detail.value;
  105. state.model.invoiceTitleType = 1;
  106. };
  107. const invoiceTitleType = (e) => {
  108. state.model.invoiceTitleType = e.detail.value;
  109. };
  110. const onSave = async () => {
  111. const validate = await common_vendor.unref(invoiceFormRef).validate().catch((error) => {
  112. console.log("error: ", error);
  113. });
  114. if (!validate) {
  115. return;
  116. }
  117. if (!state.protocol) {
  118. currentProtocol.value = true;
  119. setTimeout(function() {
  120. currentProtocol.value = false;
  121. }, 500);
  122. return;
  123. }
  124. const formData = {
  125. ...state.model
  126. };
  127. const {
  128. code
  129. } = state.model.id > 0 ? await sheep_api_member_address.AddressApi.updateAddress(formData) : await sheep_api_member_address.AddressApi.createAddress(formData);
  130. if (code === 0) {
  131. sheep_index.sheep.$router.back();
  132. }
  133. };
  134. const onDelete = () => {
  135. common_vendor.index.showModal({
  136. title: "提示",
  137. content: "确认删除此收货地址吗?",
  138. success: async function(res) {
  139. if (!res.confirm) {
  140. return;
  141. }
  142. const {
  143. code
  144. } = await sheep_api_member_address.AddressApi.deleteAddress(state.model.id);
  145. if (code === 0) {
  146. sheep_index.sheep.$router.back();
  147. }
  148. }
  149. });
  150. };
  151. common_vendor.onLoad(async (options) => {
  152. });
  153. return (_ctx, _cache) => {
  154. return common_vendor.e({
  155. a: state.model.invoiceType == 1,
  156. b: state.model.invoiceType == 2,
  157. c: common_vendor.o(invoiceType),
  158. d: common_vendor.p({
  159. name: "invoiceType",
  160. label: "发票类型"
  161. }),
  162. e: state.model.invoiceType == 1
  163. }, state.model.invoiceType == 1 ? {
  164. f: state.model.invoiceTitleType == 1,
  165. g: state.model.invoiceTitleType == 2,
  166. h: common_vendor.o(invoiceTitleType),
  167. i: common_vendor.p({
  168. name: "invoiceTitleType",
  169. label: "抬头类型"
  170. })
  171. } : {}, {
  172. j: common_vendor.o(($event) => state.model.invoiceTitle = $event),
  173. k: common_vendor.p({
  174. placeholder: "请输入发票抬头",
  175. inputBorder: false,
  176. placeholderStyle: "color:#BBBBBB;font-size:30rpx;font-weight:400;line-height:normal",
  177. modelValue: state.model.invoiceTitle
  178. }),
  179. l: common_vendor.p({
  180. name: "invoiceTitle",
  181. label: "发票抬头"
  182. }),
  183. m: state.model.invoiceTitleType == 2
  184. }, state.model.invoiceTitleType == 2 ? {
  185. n: common_vendor.o(($event) => state.model.taxIDNumber = $event),
  186. o: common_vendor.p({
  187. type: "number",
  188. placeholder: "请输入单位税号",
  189. inputBorder: false,
  190. placeholderStyle: "color:#BBBBBB;font-size:30rpx;font-weight:400;line-height:normal",
  191. modelValue: state.model.taxIDNumber
  192. }),
  193. p: common_vendor.p({
  194. name: "taxIDNumber",
  195. label: "单位税号"
  196. }),
  197. q: common_vendor.o(($event) => state.model.invoiceTitle = $event),
  198. r: common_vendor.p({
  199. type: "number",
  200. placeholder: "选填",
  201. inputBorder: false,
  202. placeholderStyle: "color:#BBBBBB;font-size:30rpx;font-weight:400;line-height:normal",
  203. modelValue: state.model.invoiceTitle
  204. }),
  205. s: common_vendor.p({
  206. name: "invoiceTitle",
  207. label: "注册地址"
  208. }),
  209. t: common_vendor.o(($event) => state.model.invoiceTitle = $event),
  210. v: common_vendor.p({
  211. type: "number",
  212. placeholder: "选填",
  213. inputBorder: false,
  214. placeholderStyle: "color:#BBBBBB;font-size:30rpx;font-weight:400;line-height:normal",
  215. modelValue: state.model.invoiceTitle
  216. }),
  217. w: common_vendor.p({
  218. name: "invoiceTitle",
  219. label: "注册电话"
  220. }),
  221. x: common_vendor.o(($event) => state.model.invoiceTitle = $event),
  222. y: common_vendor.p({
  223. type: "number",
  224. placeholder: "选填",
  225. inputBorder: false,
  226. placeholderStyle: "color:#BBBBBB;font-size:30rpx;font-weight:400;line-height:normal",
  227. modelValue: state.model.invoiceTitle
  228. }),
  229. z: common_vendor.p({
  230. name: "invoiceTitle",
  231. label: "开户银行"
  232. }),
  233. A: common_vendor.o(($event) => state.model.invoiceTitle = $event),
  234. B: common_vendor.p({
  235. type: "number",
  236. placeholder: "选填",
  237. inputBorder: false,
  238. placeholderStyle: "color:#BBBBBB;font-size:30rpx;font-weight:400;line-height:normal",
  239. modelValue: state.model.invoiceTitle
  240. }),
  241. C: common_vendor.p({
  242. name: "invoiceTitle",
  243. label: "银行账号"
  244. })
  245. } : {}, {
  246. D: state.model.invoiceType == 2
  247. }, state.model.invoiceType == 2 ? {
  248. E: common_vendor.o(($event) => state.model.taxIDNumber = $event),
  249. F: common_vendor.p({
  250. type: "number",
  251. placeholder: "请输入单位税号",
  252. inputBorder: false,
  253. placeholderStyle: "color:#BBBBBB;font-size:30rpx;font-weight:400;line-height:normal",
  254. modelValue: state.model.taxIDNumber
  255. }),
  256. G: common_vendor.p({
  257. name: "taxIDNumber",
  258. label: "单位税号"
  259. }),
  260. H: common_vendor.o(($event) => state.model.invoiceTitle = $event),
  261. I: common_vendor.p({
  262. type: "number",
  263. placeholder: "必填",
  264. inputBorder: false,
  265. placeholderStyle: "color:#BBBBBB;font-size:30rpx;font-weight:400;line-height:normal",
  266. modelValue: state.model.invoiceTitle
  267. }),
  268. J: common_vendor.p({
  269. name: "invoiceTitle",
  270. label: "注册地址"
  271. }),
  272. K: common_vendor.o(($event) => state.model.invoiceTitle = $event),
  273. L: common_vendor.p({
  274. type: "number",
  275. placeholder: "必填",
  276. inputBorder: false,
  277. placeholderStyle: "color:#BBBBBB;font-size:30rpx;font-weight:400;line-height:normal",
  278. modelValue: state.model.invoiceTitle
  279. }),
  280. M: common_vendor.p({
  281. name: "invoiceTitle",
  282. label: "注册电话"
  283. }),
  284. N: common_vendor.o(($event) => state.model.invoiceTitle = $event),
  285. O: common_vendor.p({
  286. type: "number",
  287. placeholder: "必填",
  288. inputBorder: false,
  289. placeholderStyle: "color:#BBBBBB;font-size:30rpx;font-weight:400;line-height:normal",
  290. modelValue: state.model.invoiceTitle
  291. }),
  292. P: common_vendor.p({
  293. name: "invoiceTitle",
  294. label: "开户银行"
  295. }),
  296. Q: common_vendor.o(($event) => state.model.invoiceTitle = $event),
  297. R: common_vendor.p({
  298. type: "number",
  299. placeholder: "必填",
  300. inputBorder: false,
  301. placeholderStyle: "color:#BBBBBB;font-size:30rpx;font-weight:400;line-height:normal",
  302. modelValue: state.model.invoiceTitle
  303. }),
  304. S: common_vendor.p({
  305. name: "invoiceTitle",
  306. label: "银行账号"
  307. })
  308. } : {}, {
  309. T: state.model.invoiceType == 2
  310. }, state.model.invoiceType == 2 ? {
  311. U: state.protocol,
  312. V: common_vendor.o(onChange),
  313. W: common_vendor.o(($event) => onProtocol("专用发票抬头确认书")),
  314. X: common_vendor.o(onChange),
  315. Y: currentProtocol.value ? 1 : ""
  316. } : {}, {
  317. Z: common_vendor.sr(invoiceFormRef, "1891008f-1,1891008f-0", {
  318. "k": "invoiceFormRef"
  319. }),
  320. aa: common_vendor.o(($event) => state.model = $event),
  321. ab: common_vendor.p({
  322. rules,
  323. validateTrigger: "bind",
  324. labelWidth: "160",
  325. labelAlign: "left",
  326. border: true,
  327. labelStyle: {
  328. fontWeight: "bold"
  329. },
  330. modelValue: state.model
  331. }),
  332. ac: common_vendor.o(onSave),
  333. ad: state.model.id
  334. }, state.model.id ? {
  335. ae: common_vendor.o(onDelete)
  336. } : {}, {
  337. af: common_vendor.p({
  338. bottom: true,
  339. opacity: false,
  340. bg: "",
  341. placeholder: true,
  342. noFixed: false,
  343. index: 10
  344. }),
  345. ag: common_vendor.p({
  346. title: state.model.id ? "编辑发票抬头" : "新增发票抬头"
  347. })
  348. });
  349. };
  350. }
  351. };
  352. const MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["__scopeId", "data-v-1891008f"], ["__file", "D:/zx/mall-front-app/pages/user/invoice/edit.vue"]]);
  353. wx.createPage(MiniProgramPage);